storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/pkg/s3select/unused-errors.go (about) 1 //go:build ignore 2 // +build ignore 3 4 /* 5 * MinIO Cloud Storage, (C) 2019 MinIO, Inc. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 package s3select 21 22 /////////////////////////////////////////////////////////////////////// 23 // 24 // Validation errors. 25 // 26 /////////////////////////////////////////////////////////////////////// 27 func errExpressionTooLong(err error) *s3Error { 28 return &s3Error{ 29 code: "ExpressionTooLong", 30 message: "The SQL expression is too long: The maximum byte-length for the SQL expression is 256 KB.", 31 statusCode: 400, 32 cause: err, 33 } 34 } 35 36 func errColumnTooLong(err error) *s3Error { 37 return &s3Error{ 38 code: "ColumnTooLong", 39 message: "The length of a column in the result is greater than maxCharsPerColumn of 1 MB.", 40 statusCode: 400, 41 cause: err, 42 } 43 } 44 45 func errOverMaxColumn(err error) *s3Error { 46 return &s3Error{ 47 code: "OverMaxColumn", 48 message: "The number of columns in the result is greater than the maximum allowable number of columns.", 49 statusCode: 400, 50 cause: err, 51 } 52 } 53 54 func errOverMaxRecordSize(err error) *s3Error { 55 return &s3Error{ 56 code: "OverMaxRecordSize", 57 message: "The length of a record in the input or result is greater than maxCharsPerRecord of 1 MB.", 58 statusCode: 400, 59 cause: err, 60 } 61 } 62 63 func errInvalidColumnIndex(err error) *s3Error { 64 return &s3Error{ 65 code: "InvalidColumnIndex", 66 message: "Column index in the SQL expression is invalid.", 67 statusCode: 400, 68 cause: err, 69 } 70 } 71 72 func errInvalidTextEncoding(err error) *s3Error { 73 return &s3Error{ 74 code: "InvalidTextEncoding", 75 message: "Invalid encoding type. Only UTF-8 encoding is supported.", 76 statusCode: 400, 77 cause: err, 78 } 79 } 80 81 func errInvalidTableAlias(err error) *s3Error { 82 return &s3Error{ 83 code: "InvalidTableAlias", 84 message: "The SQL expression contains an invalid table alias.", 85 statusCode: 400, 86 cause: err, 87 } 88 } 89 90 func errUnsupportedSyntax(err error) *s3Error { 91 return &s3Error{ 92 code: "UnsupportedSyntax", 93 message: "Encountered invalid syntax.", 94 statusCode: 400, 95 cause: err, 96 } 97 } 98 99 func errAmbiguousFieldName(err error) *s3Error { 100 return &s3Error{ 101 code: "AmbiguousFieldName", 102 message: "Field name matches to multiple fields in the file. Check the SQL expression and the file, and try again.", 103 statusCode: 400, 104 cause: err, 105 } 106 } 107 108 func errIntegerOverflow(err error) *s3Error { 109 return &s3Error{ 110 code: "IntegerOverflow", 111 message: "Integer overflow or underflow in the SQL expression.", 112 statusCode: 400, 113 cause: err, 114 } 115 } 116 117 func errIllegalSQLFunctionArgument(err error) *s3Error { 118 return &s3Error{ 119 code: "IllegalSqlFunctionArgument", 120 message: "Illegal argument was used in the SQL function.", 121 statusCode: 400, 122 cause: err, 123 } 124 } 125 126 func errMultipleDataSourcesUnsupported(err error) *s3Error { 127 return &s3Error{ 128 code: "MultipleDataSourcesUnsupported", 129 message: "Multiple data sources are not supported.", 130 statusCode: 400, 131 cause: err, 132 } 133 } 134 135 func errMissingHeaders(err error) *s3Error { 136 return &s3Error{ 137 code: "MissingHeaders", 138 message: "Some headers in the query are missing from the file. Check the file and try again.", 139 statusCode: 400, 140 cause: err, 141 } 142 } 143 144 func errUnrecognizedFormatException(err error) *s3Error { 145 return &s3Error{ 146 code: "UnrecognizedFormatException", 147 message: "Encountered an invalid record type.", 148 statusCode: 400, 149 cause: err, 150 } 151 } 152 153 ////////////////////////////////////////////////////////////////////////////////////// 154 // 155 // SQL parsing errors. 156 // 157 ////////////////////////////////////////////////////////////////////////////////////// 158 func errLexerInvalidChar(err error) *s3Error { 159 return &s3Error{ 160 code: "LexerInvalidChar", 161 message: "The SQL expression contains an invalid character.", 162 statusCode: 400, 163 cause: err, 164 } 165 } 166 167 func errLexerInvalidOperator(err error) *s3Error { 168 return &s3Error{ 169 code: "LexerInvalidOperator", 170 message: "The SQL expression contains an invalid literal.", 171 statusCode: 400, 172 cause: err, 173 } 174 } 175 176 func errLexerInvalidLiteral(err error) *s3Error { 177 return &s3Error{ 178 code: "LexerInvalidLiteral", 179 message: "The SQL expression contains an invalid operator.", 180 statusCode: 400, 181 cause: err, 182 } 183 } 184 185 func errLexerInvalidIONLiteral(err error) *s3Error { 186 return &s3Error{ 187 code: "LexerInvalidIONLiteral", 188 message: "The SQL expression contains an invalid operator.", 189 statusCode: 400, 190 cause: err, 191 } 192 } 193 194 func errParseExpectedDatePart(err error) *s3Error { 195 return &s3Error{ 196 code: "ParseExpectedDatePart", 197 message: "Did not find the expected date part in the SQL expression.", 198 statusCode: 400, 199 cause: err, 200 } 201 } 202 203 func errParseExpectedKeyword(err error) *s3Error { 204 return &s3Error{ 205 code: "ParseExpectedKeyword", 206 message: "Did not find the expected keyword in the SQL expression.", 207 statusCode: 400, 208 cause: err, 209 } 210 } 211 212 func errParseExpectedTokenType(err error) *s3Error { 213 return &s3Error{ 214 code: "ParseExpectedTokenType", 215 message: "Did not find the expected token in the SQL expression.", 216 statusCode: 400, 217 cause: err, 218 } 219 } 220 221 func errParseExpected2TokenTypes(err error) *s3Error { 222 return &s3Error{ 223 code: "ParseExpected2TokenTypes", 224 message: "Did not find the expected token in the SQL expression.", 225 statusCode: 400, 226 cause: err, 227 } 228 } 229 230 func errParseExpectedNumber(err error) *s3Error { 231 return &s3Error{ 232 code: "ParseExpectedNumber", 233 message: "Did not find the expected number in the SQL expression.", 234 statusCode: 400, 235 cause: err, 236 } 237 } 238 239 func errParseExpectedRightParenBuiltinFunctionCall(err error) *s3Error { 240 return &s3Error{ 241 code: "ParseExpectedRightParenBuiltinFunctionCall", 242 message: "Did not find the expected right parenthesis character in the SQL expression.", 243 statusCode: 400, 244 cause: err, 245 } 246 } 247 248 func errParseExpectedTypeName(err error) *s3Error { 249 return &s3Error{ 250 code: "ParseExpectedTypeName", 251 message: "Did not find the expected type name in the SQL expression.", 252 statusCode: 400, 253 cause: err, 254 } 255 } 256 257 func errParseExpectedWhenClause(err error) *s3Error { 258 return &s3Error{ 259 code: "ParseExpectedWhenClause", 260 message: "Did not find the expected WHEN clause in the SQL expression. CASE is not supported.", 261 statusCode: 400, 262 cause: err, 263 } 264 } 265 266 func errParseUnsupportedToken(err error) *s3Error { 267 return &s3Error{ 268 code: "ParseUnsupportedToken", 269 message: "The SQL expression contains an unsupported token.", 270 statusCode: 400, 271 cause: err, 272 } 273 } 274 275 func errParseUnsupportedLiteralsGroupBy(err error) *s3Error { 276 return &s3Error{ 277 code: "ParseUnsupportedLiteralsGroupBy", 278 message: "The SQL expression contains an unsupported use of GROUP BY.", 279 statusCode: 400, 280 cause: err, 281 } 282 } 283 284 func errParseExpectedMember(err error) *s3Error { 285 return &s3Error{ 286 code: "ParseExpectedMember", 287 message: "The SQL expression contains an unsupported use of MEMBER.", 288 statusCode: 400, 289 cause: err, 290 } 291 } 292 293 func errParseUnsupportedCase(err error) *s3Error { 294 return &s3Error{ 295 code: "ParseUnsupportedCase", 296 message: "The SQL expression contains an unsupported use of CASE.", 297 statusCode: 400, 298 cause: err, 299 } 300 } 301 302 func errParseUnsupportedCaseClause(err error) *s3Error { 303 return &s3Error{ 304 code: "ParseUnsupportedCaseClause", 305 message: "The SQL expression contains an unsupported use of CASE.", 306 statusCode: 400, 307 cause: err, 308 } 309 } 310 311 func errParseUnsupportedAlias(err error) *s3Error { 312 return &s3Error{ 313 code: "ParseUnsupportedAlias", 314 message: "The SQL expression contains an unsupported use of ALIAS.", 315 statusCode: 400, 316 cause: err, 317 } 318 } 319 320 func errParseInvalidPathComponent(err error) *s3Error { 321 return &s3Error{ 322 code: "ParseInvalidPathComponent", 323 message: "The SQL expression contains an invalid path component.", 324 statusCode: 400, 325 cause: err, 326 } 327 } 328 329 func errParseMissingIdentAfterAt(err error) *s3Error { 330 return &s3Error{ 331 code: "ParseMissingIdentAfterAt", 332 message: "Did not find the expected identifier after the @ symbol in the SQL expression.", 333 statusCode: 400, 334 cause: err, 335 } 336 } 337 338 func errParseUnexpectedOperator(err error) *s3Error { 339 return &s3Error{ 340 code: "ParseUnexpectedOperator", 341 message: "The SQL expression contains an unexpected operator.", 342 statusCode: 400, 343 cause: err, 344 } 345 } 346 347 func errParseUnexpectedTerm(err error) *s3Error { 348 return &s3Error{ 349 code: "ParseUnexpectedTerm", 350 message: "The SQL expression contains an unexpected term.", 351 statusCode: 400, 352 cause: err, 353 } 354 } 355 356 func errParseUnexpectedToken(err error) *s3Error { 357 return &s3Error{ 358 code: "ParseUnexpectedToken", 359 message: "The SQL expression contains an unexpected token.", 360 statusCode: 400, 361 cause: err, 362 } 363 } 364 365 func errParseUnExpectedKeyword(err error) *s3Error { 366 return &s3Error{ 367 code: "ParseUnExpectedKeyword", 368 message: "The SQL expression contains an unexpected keyword.", 369 statusCode: 400, 370 cause: err, 371 } 372 } 373 374 func errParseExpectedExpression(err error) *s3Error { 375 return &s3Error{ 376 code: "ParseExpectedExpression", 377 message: "Did not find the expected SQL expression.", 378 statusCode: 400, 379 cause: err, 380 } 381 } 382 383 func errParseExpectedLeftParenAfterCast(err error) *s3Error { 384 return &s3Error{ 385 code: "ParseExpectedLeftParenAfterCast", 386 message: "Did not find the expected left parenthesis after CAST in the SQL expression.", 387 statusCode: 400, 388 cause: err, 389 } 390 } 391 392 func errParseExpectedLeftParenValueConstructor(err error) *s3Error { 393 return &s3Error{ 394 code: "ParseExpectedLeftParenValueConstructor", 395 message: "Did not find expected the left parenthesis in the SQL expression.", 396 statusCode: 400, 397 cause: err, 398 } 399 } 400 401 func errParseExpectedLeftParenBuiltinFunctionCall(err error) *s3Error { 402 return &s3Error{ 403 code: "ParseExpectedLeftParenBuiltinFunctionCall", 404 message: "Did not find the expected left parenthesis in the SQL expression.", 405 statusCode: 400, 406 cause: err, 407 } 408 } 409 410 func errParseExpectedArgumentDelimiter(err error) *s3Error { 411 return &s3Error{ 412 code: "ParseExpectedArgumentDelimiter", 413 message: "Did not find the expected argument delimiter in the SQL expression.", 414 statusCode: 400, 415 cause: err, 416 } 417 } 418 419 func errParseCastArity(err error) *s3Error { 420 return &s3Error{ 421 code: "ParseCastArity", 422 message: "The SQL expression CAST has incorrect arity.", 423 statusCode: 400, 424 cause: err, 425 } 426 } 427 428 func errParseEmptySelect(err error) *s3Error { 429 return &s3Error{ 430 code: "ParseEmptySelect", 431 message: "The SQL expression contains an empty SELECT.", 432 statusCode: 400, 433 cause: err, 434 } 435 } 436 437 func errParseSelectMissingFrom(err error) *s3Error { 438 return &s3Error{ 439 code: "ParseSelectMissingFrom", 440 message: "The SQL expression contains a missing FROM after SELECT list.", 441 statusCode: 400, 442 cause: err, 443 } 444 } 445 446 func errParseExpectedIdentForGroupName(err error) *s3Error { 447 return &s3Error{ 448 code: "ParseExpectedIdentForGroupName", 449 message: "GROUP is not supported in the SQL expression.", 450 statusCode: 400, 451 cause: err, 452 } 453 } 454 455 func errParseExpectedIdentForAlias(err error) *s3Error { 456 return &s3Error{ 457 code: "ParseExpectedIdentForAlias", 458 message: "Did not find the expected identifier for the alias in the SQL expression.", 459 statusCode: 400, 460 cause: err, 461 } 462 } 463 464 func errParseUnsupportedCallWithStar(err error) *s3Error { 465 return &s3Error{ 466 code: "ParseUnsupportedCallWithStar", 467 message: "Only COUNT with (*) as a parameter is supported in the SQL expression.", 468 statusCode: 400, 469 cause: err, 470 } 471 } 472 473 func errParseMalformedJoin(err error) *s3Error { 474 return &s3Error{ 475 code: "ParseMalformedJoin", 476 message: "JOIN is not supported in the SQL expression.", 477 statusCode: 400, 478 cause: err, 479 } 480 } 481 482 func errParseExpectedIdentForAt(err error) *s3Error { 483 return &s3Error{ 484 code: "ParseExpectedIdentForAt", 485 message: "Did not find the expected identifier for AT name in the SQL expression.", 486 statusCode: 400, 487 cause: err, 488 } 489 } 490 491 func errParseCannotMixSqbAndWildcardInSelectList(err error) *s3Error { 492 return &s3Error{ 493 code: "ParseCannotMixSqbAndWildcardInSelectList", 494 message: "Cannot mix [] and * in the same expression in a SELECT list in SQL expression.", 495 statusCode: 400, 496 cause: err, 497 } 498 } 499 500 ////////////////////////////////////////////////////////////////////////////////////// 501 // 502 // CAST() related errors. 503 // 504 ////////////////////////////////////////////////////////////////////////////////////// 505 func errCastFailed(err error) *s3Error { 506 return &s3Error{ 507 code: "CastFailed", 508 message: "Attempt to convert from one data type to another using CAST failed in the SQL expression.", 509 statusCode: 400, 510 cause: err, 511 } 512 } 513 514 func errInvalidCast(err error) *s3Error { 515 return &s3Error{ 516 code: "InvalidCast", 517 message: "Attempt to convert from one data type to another using CAST failed in the SQL expression.", 518 statusCode: 400, 519 cause: err, 520 } 521 } 522 523 func errEvaluatorInvalidTimestampFormatPattern(err error) *s3Error { 524 return &s3Error{ 525 code: "EvaluatorInvalidTimestampFormatPattern", 526 message: "Invalid time stamp format string in the SQL expression.", 527 statusCode: 400, 528 cause: err, 529 } 530 } 531 532 func errEvaluatorInvalidTimestampFormatPatternAdditionalFieldsRequired(err error) *s3Error { 533 return &s3Error{ 534 code: "EvaluatorInvalidTimestampFormatPattern", 535 message: "Time stamp format pattern requires additional fields in the SQL expression.", 536 statusCode: 400, 537 cause: err, 538 } 539 } 540 541 func errEvaluatorInvalidTimestampFormatPatternSymbolForParsing(err error) *s3Error { 542 return &s3Error{ 543 code: "EvaluatorInvalidTimestampFormatPatternSymbolForParsing", 544 message: "Time stamp format pattern contains a valid format symbol that cannot be applied to time stamp parsing in the SQL expression.", 545 statusCode: 400, 546 cause: err, 547 } 548 } 549 550 func errEvaluatorTimestampFormatPatternDuplicateFields(err error) *s3Error { 551 return &s3Error{ 552 code: "EvaluatorTimestampFormatPatternDuplicateFields", 553 message: "Time stamp format pattern contains multiple format specifiers representing the time stamp field in the SQL expression.", 554 statusCode: 400, 555 cause: err, 556 } 557 } 558 559 func errEvaluatorTimestampFormatPatternHourClockAmPmMismatch(err error) *s3Error { 560 return &s3Error{ 561 code: "EvaluatorTimestampFormatPatternHourClockAmPmMismatch", 562 message: "Time stamp format pattern contains a 12-hour hour of day format symbol but doesn't also contain an AM/PM field, or it contains a 24-hour hour of day format specifier and contains an AM/PM field in the SQL expression.", 563 statusCode: 400, 564 cause: err, 565 } 566 } 567 568 func errEvaluatorUnterminatedTimestampFormatPatternToken(err error) *s3Error { 569 return &s3Error{ 570 code: "EvaluatorUnterminatedTimestampFormatPatternToken", 571 message: "Time stamp format pattern contains unterminated token in the SQL expression.", 572 statusCode: 400, 573 cause: err, 574 } 575 } 576 577 func errEvaluatorInvalidTimestampFormatPatternToken(err error) *s3Error { 578 return &s3Error{ 579 code: "EvaluatorInvalidTimestampFormatPatternToken", 580 message: "Time stamp format pattern contains an invalid token in the SQL expression.", 581 statusCode: 400, 582 cause: err, 583 } 584 } 585 586 func errEvaluatorInvalidTimestampFormatPatternSymbol(err error) *s3Error { 587 return &s3Error{ 588 code: "EvaluatorInvalidTimestampFormatPatternSymbol", 589 message: "Time stamp format pattern contains an invalid symbol in the SQL expression.", 590 statusCode: 400, 591 cause: err, 592 } 593 } 594 595 //////////////////////////////////////////////////////////////////////// 596 // 597 // Generic S3 HTTP handler errors. 598 // 599 //////////////////////////////////////////////////////////////////////// 600 func errBusy(err error) *s3Error { 601 return &s3Error{ 602 code: "Busy", 603 message: "The service is unavailable. Please retry.", 604 statusCode: 503, 605 cause: err, 606 } 607 } 608 609 func errUnauthorizedAccess(err error) *s3Error { 610 return &s3Error{ 611 code: "UnauthorizedAccess", 612 message: "You are not authorized to perform this operation", 613 statusCode: 401, 614 cause: err, 615 } 616 } 617 618 func errEmptyRequestBody(err error) *s3Error { 619 return &s3Error{ 620 code: "EmptyRequestBody", 621 message: "Request body cannot be empty.", 622 statusCode: 400, 623 cause: err, 624 } 625 } 626 627 func errUnsupportedRangeHeader(err error) *s3Error { 628 return &s3Error{ 629 code: "UnsupportedRangeHeader", 630 message: "Range header is not supported for this operation.", 631 statusCode: 400, 632 cause: err, 633 } 634 } 635 636 func errUnsupportedStorageClass(err error) *s3Error { 637 return &s3Error{ 638 code: "UnsupportedStorageClass", 639 message: "Encountered an invalid storage class. Only STANDARD, STANDARD_IA, and ONEZONE_IA storage classes are supported.", 640 statusCode: 400, 641 cause: err, 642 } 643 }