{"record":{"id":"f047209bdeb8a2d1","repo":"apache/beam","slug":"create-table-is-not-supported-in-sql-you-can-use-create","errorCode":null,"errorMessage":"'CREATE TABLE' is not supported in SQL. You can use 'CREATE EXTERNAL TABLE' to register an external data source to SQL. For more details, please check: https://beam.apache.org/documentation/dsls/sql/create-external-table","messagePattern":"'CREATE TABLE' is not supported in SQL\\. You can use 'CREATE EXTERNAL TABLE' to register an external data source to SQL\\. For more details, please check: https://beam\\.apache\\.org/documentation/dsls/sql/create-external-table","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/codegen/includes/parserImpls.ftl","lineNumber":693,"sourceCode":"        jarName = StringLiteral()\n    {\n        return\n            new SqlCreateFunction(\n                s.end(this),\n                replace,\n                name,\n                jarName,\n                isAggregate);\n    }\n}\n\nSqlCreate SqlCreateTableNotSupportedMessage(Span s, boolean replace) :\n{\n}\n{\n  <TABLE>\n  {\n    throw new ParseException(\"'CREATE TABLE' is not supported in SQL. You can use \"\n    + \"'CREATE EXTERNAL TABLE' to register an external data source to SQL. For more details, \"\n    + \"please check: https://beam.apache.org/documentation/dsls/sql/create-external-table\");\n  }\n}\n\nSqlDrop SqlDropTable(Span s, boolean replace) :\n{\n    final boolean ifExists;\n    final SqlIdentifier id;\n}\n{\n    <TABLE> ifExists = IfExistsOpt() id = CompoundIdentifier() {\n        return SqlDdlNodes.dropTable(s.end(this), ifExists, id);\n    }\n}\n\n/**\n * SHOW TABLES [ ( FROM | IN )? [ catalog_name '.' ] database_name ] [ LIKE regex_pattern ]","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/codegen/includes/parserImpls.ftl#L675-L711","documentation":"A deliberate parse error: Beam SQL's grammar has no CREATE TABLE support. When the parser sees CREATE TABLE it immediately throws this ParseException pointing users to CREATE EXTERNAL TABLE, which is Beam SQL's mechanism to register an external data source.","triggerScenarios":"Running any statement of the form CREATE TABLE [IF NOT EXISTS] name (...) (or CREATE OR REPLACE TABLE) through BeamSql / SqlTransform; also triggered by CREATE REPLACE TABLE via the replace flag routing into this production.","commonSituations":"Porting DDL from Hive/Spark SQL/MySQL into Beam SQL pipelines; generating schema-based pipelines where authors assume standard CREATE TABLE; old tutorials/scripts.","solutions":["Rewrite the statement as CREATE EXTERNAL TABLE ... (type, location) to register the data source.","For in-memory data, construct a PCollection with a schema and apply SqlTransform.query instead of DDL.","Consult https://beam.apache.org/documentation/dsls/sql/create-external-table for the supported syntax."],"exampleFix":"// before\nCREATE TABLE orders (id INT, amount DOUBLE);\n// after\nCREATE EXTERNAL TABLE orders (id INT, amount DOUBLE)\nTYPE 'csv'\nLOCATION '/path/to/orders/';","handlingStrategy":"validation","validationCode":"// reject unsupported DDL before handing to Beam SQL\nstatic void rejectCreateTable(String sql) {\n  if (sql.trim().toUpperCase().matches(\"^CREATE\\\\s+(OR\\\\s+REPLACE\\\\s+)?TABLE\\\\b.*\")) {\n    throw new IllegalArgumentException(\"Use CREATE EXTERNAL TABLE instead of CREATE TABLE in Beam SQL.\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  result = pipeline.apply(SqlTransform.query(sql));\n} catch (ParseException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"'CREATE TABLE' is not supported\")) {\n    throw new IllegalArgumentException(\"Rewrite as CREATE EXTERNAL TABLE ... TYPE ... LOCATION ...\", e);\n  }\n  throw e;\n}","preventionTips":["Always use CREATE EXTERNAL TABLE with TYPE and LOCATION for data source registration.","Add a SQL lint step that rejects standard CREATE TABLE DDL in Beam pipelines.","When porting from other SQL engines, review all DDL statements for Beam SQL support."],"tags":["java","sql","parser","beam-sql","ddl"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}