{"record":{"id":"7966853d6ffa9f78","repo":"rustfs/rustfs","slug":"incorrectsqlfunctionargumenttype","errorCode":"IncorrectSqlFunctionArgumentType","errorMessage":"An incorrect argument type was specified in a function call in the SQL expression.","messagePattern":"An incorrect argument type was specified in a function call in the SQL expression\\.","errorType":"http","errorClass":"SelectError","httpStatus":400,"severity":"error","filePath":"crates/s3select-api/src/lib.rs","lineNumber":106,"sourceCode":"    #[error(\"An error occurred while parsing the CSV file. Check the file and try again.\")]\n    CsvParsingError,\n\n    #[error(\"An error occurred while parsing the JSON file. Check the file and try again.\")]\n    JsonParsingError,\n\n    #[error(\"An error occurred while parsing the Parquet file. Check the file and try again.\")]\n    ParquetParsingError,\n\n    #[error(\"{message}\")]\n    ParseSelectFailure { message: String },\n\n    #[error(\"The SQL expression is invalid.\")]\n    InvalidQuery,\n\n    #[error(\"The SQL expression contains a data type that is not valid.\")]\n    InvalidDataType,\n\n    #[error(\"An incorrect argument type was specified in a function call in the SQL expression.\")]\n    IncorrectSqlFunctionArgumentType,\n\n    #[error(\"The data source path in the SQL expression is not supported.\")]\n    DataSourcePathUnsupported,\n\n    #[error(\"Unsupported S3 Select SQL structure: {message}\")]\n    UnsupportedSqlStructure { message: String },\n\n    #[error(\"We encountered an unsupported SQL operation.\")]\n    UnsupportedSqlOperation,\n\n    #[error(\"A column name or a path provided does not exist in the SQL expression.\")]\n    EvaluatorBindingDoesNotExist,\n\n    #[error(\"The field name matches to multiple fields in the file. Check the SQL expression and the file, and try again.\")]\n    AmbiguousFieldName,\n\n    #[error(\"The value of a parameter in ScanRange element is invalid. Check the service API documentation and try again.\")]","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/rustfs/rustfs/blob/35af688cd9d41b4346fbe27dcf7250ba72046c1f/crates/s3select-api/src/lib.rs#L88-L124","documentation":"SelectError::IncorrectSqlFunctionArgumentType is produced by the planner error classifier (crates/s3select-query/src/sql/planner.rs:84-96): DataFusion plan errors matching \"Failed to coerce arguments to satisfy a call to ...\" or \"Function '...' failed to match any signature\" are reclassified to it. A function call's arguments could not be coerced to any signature of that function.","triggerScenarios":"Calling a SQL function with arguments of the wrong type: string functions on numeric columns without CAST, SUBSTRING with non-integer bounds, date functions on untyped strings, literals that infer to an unexpected type.","commonSituations":"Column types differing from what the expression assumes (VARCHAR vs INT); examples copied from another dialect; implicit-conversion expectations from loosely typed engines.","solutions":["CAST each argument to the function's documented parameter type","Check the column's inferred type from the file schema before writing the expression","Prefer explicit literals/casts over relying on implicit coercion"],"exampleFix":"-- before: SUBSTRING on a numeric column\nSELECT SUBSTRING(order_id FROM 1 FOR 2) FROM S3Object;\n\n-- after\nSELECT SUBSTRING(CAST(order_id AS VARCHAR) FROM 1 FOR 2) FROM S3Object;","handlingStrategy":"validation","validationCode":"// Check argument types against the inferred schema before sending the query.\nlet schema = infer_object_schema(&key).await?; // from header or sampling\nfor call in extract_function_calls(&request.expression) {\n    for arg in call.args {\n        let ty = resolve_type(&arg, &schema)?;\n        ensure_coercible(&ty, &call.expected_arg_types)?;\n    }\n}","typeGuard":null,"tryCatchPattern":"match select_object_content(req).await {\n    Ok(resp) => { /* records */ }\n    Err(e) if matches!(e.select_error(), SelectError::IncorrectSqlFunctionArgumentType) => {\n        // Add explicit CASTs so each argument matches the function signature, then resend.\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["CAST string/numeric boundaries explicitly at every function call site","Consult the function signature list when writing expressions against typed columns"],"tags":["s3-select","sql","function-arguments","types"],"backgroundTag":"sql-function-argument-type-mismatch","analyzedSha":"35af688cd9d41b4346fbe27dcf7250ba72046c1f","analyzedAt":"2026-08-20T21:57:04.799Z","contentChangedAt":"2026-08-20T21:57:04.799Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}