{"record":{"id":"1ca6f61dab5e6279","repo":"apache/seatunnel","slug":"sql-operation-failed-1ca6f6","errorCode":"SQL_OPERATION_FAILED","errorMessage":"Either SQL, query, or both database and table must be specified","messagePattern":"Either SQL, query, or both database and table must be specified","errorType":"error_code","errorClass":"DatabendConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/source/DatabendSourceFactory.java","lineNumber":144,"sourceCode":"    /** according to the options, build the SQL statement */\n    private String buildSqlStatement(ReadonlyConfig options) {\n        if (options.getOptional(DatabendSourceOptions.SQL).isPresent()) {\n            return options.get(DatabendSourceOptions.SQL);\n        }\n\n        String query = options.getOptional(DatabendOptions.QUERY).orElse(null);\n        if (query != null) {\n            return query;\n        }\n\n        String database = options.getOptional(DATABASE).orElse(null);\n        String table = options.getOptional(DatabendOptions.TABLE).orElse(null);\n\n        if (database != null && table != null) {\n            return String.format(\"SELECT * FROM %s.%s\", database, table);\n        }\n\n        throw new DatabendConnectorException(\n                DatabendConnectorErrorCode.SQL_OPERATION_FAILED,\n                \"Either SQL, query, or both database and table must be specified\");\n    }\n}\n","sourceCodeStart":126,"sourceCodeEnd":149,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/source/DatabendSourceFactory.java#L126-L149","documentation":"DatabendSourceFactory.buildSqlStatement constructs the source query from the user's options. The user must provide sql, or query, or both database and table. When none of these resolve to a statement, DatabendConnectorException(SQL_OPERATION_FAILED) is thrown because the connector has nothing to read.","triggerScenarios":"Source options omit all three: no sql, no query, and at least one of database/table is missing or null; option keys misspelled so getOptional returns empty.","commonSituations":"Hand-written HOCON config missing the table option; typo like databse/table_name; copying a template and deleting placeholder values; dynamically generated configs where an empty string was passed (note: empty string may still pass null checks — supply real values).","solutions":["Add both database and table options to the Databend source config.","Or provide a full sql (or query) option instead of database/table.","Check for typos in option keys against DatabendOptions (SQL, QUERY, DATABASE, TABLE).","Validate the config file renders non-empty values (no unresolved placeholders/variables)."],"exampleFix":"// before\nsource {\n  Databend {\n    url = \"jdbc:databend://localhost:8000\"\n  }\n}\n// after\nsource {\n  Databend {\n    url = \"jdbc:databend://localhost:8000\"\n    database = \"mydb\"\n    table = \"my_table\"\n  }\n}","handlingStrategy":"validation","validationCode":"// validate source options before job submission\nboolean hasSql = sql != null && !sql.isEmpty();\nboolean hasQuery = query != null && !query.isEmpty();\nboolean hasDbTable = database != null && !database.isEmpty()\n                 && table != null && !table.isEmpty();\nif (!hasSql && !hasQuery && !hasDbTable) {\n    throw new IllegalArgumentException(\"Provide sql, query, or database+table for Databend source\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    sourceFactory.createSource(options);\n} catch (DatabendConnectorException e) {\n    if (e.getMessage().contains(\"Either SQL, query, or both database and table\")) {\n        log.error(\"Databend source config incomplete: set database+table or sql/query\");\n    } else throw e;\n}","preventionTips":["Always set database and table (or a full sql/query) in the source config","Check option key spelling against DatabendOptions constants","Avoid empty-string values that bypass null checks","Lint generated configs for unresolved placeholders before submission"],"tags":["databend","source","config","sql"],"backgroundTag":"missing-required-config-field","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}