sqlglot.generators.starrocks
1from __future__ import annotations 2 3import typing as t 4 5from sqlglot import exp, transforms 6from sqlglot.dialects.dialect import ( 7 approx_count_distinct_sql, 8 arrow_json_extract_sql, 9 rename_func, 10 weekstart_unit_to_str, 11 inline_array_sql, 12 property_sql, 13 var_map_sql, 14) 15from sqlglot.generator import Generator 16from sqlglot.generators.mysql import MySQLGenerator 17 18 19def _eliminate_between_in_delete(expression: exp.Expr) -> exp.Expr: 20 """ 21 StarRocks doesn't support BETWEEN in DELETE statements, so we convert 22 BETWEEN expressions to explicit comparisons. 23 24 https://docs.starrocks.io/docs/sql-reference/sql-statements/table_bucket_part_index/DELETE/#parameters 25 26 Example: 27 >>> from sqlglot import parse_one 28 >>> expr = parse_one("DELETE FROM t WHERE x BETWEEN 1 AND 10") 29 >>> print(_eliminate_between_in_delete(expr).sql(dialect="starrocks")) 30 DELETE FROM t WHERE x >= 1 AND x <= 10 31 """ 32 if where := expression.args.get("where"): 33 for between in where.find_all(exp.Between): 34 between.replace( 35 exp.and_( 36 exp.GTE(this=between.this.copy(), expression=between.args["low"]), 37 exp.LTE(this=between.this.copy(), expression=between.args["high"]), 38 copy=False, 39 ) 40 ) 41 return expression 42 43 44# https://docs.starrocks.io/docs/sql-reference/sql-functions/spatial-functions/st_distance_sphere/ 45def st_distance_sphere(self, expression: exp.StDistance) -> str: 46 point1 = expression.this 47 point2 = expression.expression 48 49 point1_x = self.func("ST_X", point1) 50 point1_y = self.func("ST_Y", point1) 51 point2_x = self.func("ST_X", point2) 52 point2_y = self.func("ST_Y", point2) 53 54 return self.func("ST_Distance_Sphere", point1_x, point1_y, point2_x, point2_y) 55 56 57class StarRocksGenerator(MySQLGenerator): 58 EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE = False 59 JSON_TYPE_REQUIRED_FOR_EXTRACTION = False 60 VARCHAR_REQUIRES_SIZE = False 61 PARSE_JSON_NAME: str | None = "PARSE_JSON" 62 WITH_PROPERTIES_PREFIX = "PROPERTIES" 63 UPDATE_STATEMENT_SUPPORTS_FROM = True 64 INSERT_OVERWRITE = " OVERWRITE" 65 66 # StarRocks doesn't support "IS TRUE/FALSE" syntax. 67 IS_BOOL_ALLOWED = False 68 # StarRocks doesn't support renaming a table with a database. 69 RENAME_TABLE_WITH_DB = False 70 71 CAST_MAPPING: t.ClassVar[dict[exp.DType, str]] = {} 72 73 TYPE_MAPPING = { 74 **MySQLGenerator.TYPE_MAPPING, 75 exp.DType.INT128: "LARGEINT", 76 exp.DType.TEXT: "STRING", 77 exp.DType.TIMESTAMP: "DATETIME", 78 exp.DType.TIMESTAMPTZ: "DATETIME", 79 } 80 81 SQL_SECURITY_VIEW_LOCATION: t.ClassVar = exp.Properties.Location.POST_SCHEMA 82 83 PROPERTIES_LOCATION = { 84 **MySQLGenerator.PROPERTIES_LOCATION, 85 exp.PrimaryKey: exp.Properties.Location.POST_SCHEMA, 86 exp.UniqueKeyProperty: exp.Properties.Location.POST_SCHEMA, 87 exp.RollupProperty: exp.Properties.Location.POST_SCHEMA, 88 exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA, 89 } 90 91 TRANSFORMS = { 92 # StarRocks uses the native TRIM(str, chars)/LTRIM/RTRIM function form, not 93 # MySQL's TRIM(chars FROM str) syntax, so it falls back to the base generator. 94 **{ 95 k: v for k, v in MySQLGenerator.TRANSFORMS.items() if k not in (exp.DateTrunc, exp.Trim) 96 }, 97 exp.ArgMax: rename_func("MAX_BY"), 98 exp.ArgMin: rename_func("MIN_BY"), 99 exp.Array: inline_array_sql, 100 exp.ArrayAgg: rename_func("ARRAY_AGG"), 101 # a <@ b (ArrayContainedBy) is equivalent to ARRAY_CONTAINS_ALL(b, a) 102 exp.ArrayContainedBy: lambda self, e: self.func("ARRAY_CONTAINS_ALL", e.expression, e.this), 103 exp.ArrayContainsAll: rename_func("ARRAY_CONTAINS_ALL"), 104 exp.ArrayFilter: rename_func("ARRAY_FILTER"), 105 exp.ArrayToString: rename_func("ARRAY_JOIN"), 106 exp.ApproxDistinct: approx_count_distinct_sql, 107 exp.CurrentVersion: lambda *_: "CURRENT_VERSION()", 108 exp.DateDiff: lambda self, e: self.func( 109 "DATE_DIFF", weekstart_unit_to_str(self, e), e.this, e.expression 110 ), 111 exp.Delete: transforms.preprocess([_eliminate_between_in_delete]), 112 exp.Flatten: rename_func("ARRAY_FLATTEN"), 113 exp.JSONExtractScalar: arrow_json_extract_sql, 114 exp.JSONExtract: arrow_json_extract_sql, 115 # Both MAP forms (two-array MAP([keys], [values]) and variadic MAP(k1, v1, ...)) 116 # generate StarRocks' variadic MAP(k1, v1, k2, v2, ...) constructor 117 exp.Map: lambda self, e: var_map_sql(self, e, "MAP"), 118 exp.Property: property_sql, 119 exp.RegexpLike: rename_func("REGEXP"), 120 # Inherited from MySQL, minus operations StarRocks supports natively 121 # (QUALIFY, FULL OUTER JOIN, SEMI/ANTI JOIN) 122 exp.Select: transforms.preprocess( 123 [ 124 transforms.eliminate_distinct_on, 125 transforms.unnest_generate_date_array_using_recursive_cte, 126 ] 127 ), 128 exp.SchemaCommentProperty: lambda self, e: self.naked_property(e), 129 exp.SqlSecurityProperty: lambda self, e: f"SECURITY {self.sql(e.this)}", 130 exp.StDistance: st_distance_sphere, 131 exp.StrToUnix: lambda self, e: self.func("UNIX_TIMESTAMP", e.this, self.format_time(e)), 132 exp.TimestampTrunc: lambda self, e: self.func( 133 "DATE_TRUNC", weekstart_unit_to_str(self, e), e.this 134 ), 135 exp.TimeStrToDate: rename_func("TO_DATE"), 136 exp.UnixToStr: lambda self, e: self.func("FROM_UNIXTIME", e.this, self.format_time(e)), 137 exp.UnixToTime: rename_func("FROM_UNIXTIME"), 138 exp.VarMap: lambda self, e: var_map_sql(self, e, "MAP"), 139 } 140 141 # https://docs.starrocks.io/docs/sql-reference/sql-statements/keywords/#reserved-keywords 142 RESERVED_KEYWORDS = { 143 "add", 144 "all", 145 "alter", 146 "analyze", 147 "and", 148 "array", 149 "as", 150 "asc", 151 "between", 152 "bigint", 153 "bitmap", 154 "both", 155 "by", 156 "case", 157 "char", 158 "character", 159 "check", 160 "collate", 161 "column", 162 "compaction", 163 "convert", 164 "create", 165 "cross", 166 "cube", 167 "current_date", 168 "current_role", 169 "current_time", 170 "current_timestamp", 171 "current_user", 172 "database", 173 "databases", 174 "decimal", 175 "decimalv2", 176 "decimal32", 177 "decimal64", 178 "decimal128", 179 "default", 180 "deferred", 181 "delete", 182 "dense_rank", 183 "desc", 184 "describe", 185 "distinct", 186 "double", 187 "drop", 188 "dual", 189 "else", 190 "except", 191 "exists", 192 "explain", 193 "false", 194 "first_value", 195 "float", 196 "for", 197 "force", 198 "from", 199 "full", 200 "function", 201 "grant", 202 "group", 203 "grouping", 204 "grouping_id", 205 "groups", 206 "having", 207 "hll", 208 "host", 209 "if", 210 "ignore", 211 "immediate", 212 "in", 213 "index", 214 "infile", 215 "inner", 216 "insert", 217 "int", 218 "integer", 219 "intersect", 220 "into", 221 "is", 222 "join", 223 "json", 224 "key", 225 "keys", 226 "kill", 227 "lag", 228 "largeint", 229 "last_value", 230 "lateral", 231 "lead", 232 "left", 233 "like", 234 "limit", 235 "load", 236 "localtime", 237 "localtimestamp", 238 "maxvalue", 239 "minus", 240 "mod", 241 "not", 242 "ntile", 243 "null", 244 "on", 245 "or", 246 "order", 247 "outer", 248 "outfile", 249 "over", 250 "partition", 251 "percentile", 252 "primary", 253 "procedure", 254 "qualify", 255 "range", 256 "rank", 257 "read", 258 "regexp", 259 "release", 260 "rename", 261 "replace", 262 "revoke", 263 "right", 264 "rlike", 265 "row", 266 "row_number", 267 "rows", 268 "schema", 269 "schemas", 270 "select", 271 "set", 272 "set_var", 273 "show", 274 "smallint", 275 "system", 276 "table", 277 "terminated", 278 "text", 279 "then", 280 "tinyint", 281 "to", 282 "true", 283 "union", 284 "unique", 285 "unsigned", 286 "update", 287 "use", 288 "using", 289 "values", 290 "varchar", 291 "when", 292 "where", 293 "with", 294 } 295 296 def ignorenulls_sql(self, expression: exp.IgnoreNulls) -> str: 297 # IGNORE NULLS follows the first argument, e.g. LAG(x IGNORE NULLS, 1, 0) 298 # https://docs.starrocks.io/docs/sql-reference/sql-functions/Window_function/ 299 func = expression.this 300 if isinstance(func, (exp.FirstValue, exp.LastValue, exp.Lag, exp.Lead)): 301 return self.func( 302 func.sql_name(), 303 Generator.ignorenulls_sql(self, exp.IgnoreNulls(this=func.this)), 304 func.args.get("offset"), 305 func.args.get("default"), 306 ) 307 308 return super().ignorenulls_sql(expression) 309 310 def respectnulls_sql(self, expression: exp.RespectNulls) -> str: 311 # RESPECT NULLS is the default behavior, and StarRocks rejects the keyword 312 return self.sql(expression, "this") 313 314 def create_sql(self, expression: exp.Create) -> str: 315 # Starrocks' primary key is defined outside of the schema, so we need to move it there 316 schema = expression.this 317 if isinstance(schema, exp.Schema): 318 primary_key = schema.find(exp.PrimaryKey) 319 320 if primary_key: 321 props = expression.args.get("properties") 322 323 if not props: 324 props = exp.Properties(expressions=[]) 325 expression.set("properties", props) 326 327 # Verify if the first one is an engine property. Is true then insert it after the engine, 328 # otherwise insert it at the beginning 329 engine = props.find(exp.EngineProperty) 330 engine_index = (engine.index or 0) if engine else -1 331 props.set("expressions", primary_key.pop(), engine_index + 1, overwrite=False) 332 333 return super().create_sql(expression) 334 335 def partitionedbyproperty_sql(self, expression: exp.PartitionedByProperty) -> str: 336 this = expression.this 337 if isinstance(this, exp.Schema): 338 # For MVs, StarRocks needs outer parentheses. 339 create = expression.find_ancestor(exp.Create) 340 341 sql = self.expressions(this, flat=True) 342 if (create and create.kind == "VIEW") or all( 343 isinstance(col, (exp.Column, exp.Identifier)) for col in this.expressions 344 ): 345 sql = f"({sql})" 346 347 return f"PARTITION BY {sql}" 348 349 return f"PARTITION BY {self.sql(this)}" 350 351 def clusterproperty_sql(self, expression: exp.ClusterProperty) -> str: 352 """Generate StarRocks ORDER BY clause for clustering.""" 353 if expression.this: 354 self.unsupported(f"Unsupported CLUSTER BY {self.sql(expression, 'this')}") 355 return "" 356 expressions = self.expressions(expression, flat=True) 357 return f"ORDER BY ({expressions})" 358 359 def refreshtriggerproperty_sql(self, expression: exp.RefreshTriggerProperty) -> str: 360 """Generate StarRocks REFRESH clause for materialized views. 361 There is a little difference of the syntax between StarRocks and Doris. 362 """ 363 method = self.sql(expression, "method") 364 method = f" {method}" if method else "" 365 kind = self.sql(expression, "kind") 366 kind = f" {kind}" if kind else "" 367 starts = self.sql(expression, "starts") 368 starts = f" START ({starts})" if starts else "" 369 every = self.sql(expression, "every") 370 unit = self.sql(expression, "unit") 371 every = f" EVERY (INTERVAL {every} {unit})" if every and unit else "" 372 373 return f"REFRESH{method}{kind}{starts}{every}"
46def st_distance_sphere(self, expression: exp.StDistance) -> str: 47 point1 = expression.this 48 point2 = expression.expression 49 50 point1_x = self.func("ST_X", point1) 51 point1_y = self.func("ST_Y", point1) 52 point2_x = self.func("ST_X", point2) 53 point2_y = self.func("ST_Y", point2) 54 55 return self.func("ST_Distance_Sphere", point1_x, point1_y, point2_x, point2_y)
58class StarRocksGenerator(MySQLGenerator): 59 EXCEPT_INTERSECT_SUPPORT_ALL_CLAUSE = False 60 JSON_TYPE_REQUIRED_FOR_EXTRACTION = False 61 VARCHAR_REQUIRES_SIZE = False 62 PARSE_JSON_NAME: str | None = "PARSE_JSON" 63 WITH_PROPERTIES_PREFIX = "PROPERTIES" 64 UPDATE_STATEMENT_SUPPORTS_FROM = True 65 INSERT_OVERWRITE = " OVERWRITE" 66 67 # StarRocks doesn't support "IS TRUE/FALSE" syntax. 68 IS_BOOL_ALLOWED = False 69 # StarRocks doesn't support renaming a table with a database. 70 RENAME_TABLE_WITH_DB = False 71 72 CAST_MAPPING: t.ClassVar[dict[exp.DType, str]] = {} 73 74 TYPE_MAPPING = { 75 **MySQLGenerator.TYPE_MAPPING, 76 exp.DType.INT128: "LARGEINT", 77 exp.DType.TEXT: "STRING", 78 exp.DType.TIMESTAMP: "DATETIME", 79 exp.DType.TIMESTAMPTZ: "DATETIME", 80 } 81 82 SQL_SECURITY_VIEW_LOCATION: t.ClassVar = exp.Properties.Location.POST_SCHEMA 83 84 PROPERTIES_LOCATION = { 85 **MySQLGenerator.PROPERTIES_LOCATION, 86 exp.PrimaryKey: exp.Properties.Location.POST_SCHEMA, 87 exp.UniqueKeyProperty: exp.Properties.Location.POST_SCHEMA, 88 exp.RollupProperty: exp.Properties.Location.POST_SCHEMA, 89 exp.PartitionedByProperty: exp.Properties.Location.POST_SCHEMA, 90 } 91 92 TRANSFORMS = { 93 # StarRocks uses the native TRIM(str, chars)/LTRIM/RTRIM function form, not 94 # MySQL's TRIM(chars FROM str) syntax, so it falls back to the base generator. 95 **{ 96 k: v for k, v in MySQLGenerator.TRANSFORMS.items() if k not in (exp.DateTrunc, exp.Trim) 97 }, 98 exp.ArgMax: rename_func("MAX_BY"), 99 exp.ArgMin: rename_func("MIN_BY"), 100 exp.Array: inline_array_sql, 101 exp.ArrayAgg: rename_func("ARRAY_AGG"), 102 # a <@ b (ArrayContainedBy) is equivalent to ARRAY_CONTAINS_ALL(b, a) 103 exp.ArrayContainedBy: lambda self, e: self.func("ARRAY_CONTAINS_ALL", e.expression, e.this), 104 exp.ArrayContainsAll: rename_func("ARRAY_CONTAINS_ALL"), 105 exp.ArrayFilter: rename_func("ARRAY_FILTER"), 106 exp.ArrayToString: rename_func("ARRAY_JOIN"), 107 exp.ApproxDistinct: approx_count_distinct_sql, 108 exp.CurrentVersion: lambda *_: "CURRENT_VERSION()", 109 exp.DateDiff: lambda self, e: self.func( 110 "DATE_DIFF", weekstart_unit_to_str(self, e), e.this, e.expression 111 ), 112 exp.Delete: transforms.preprocess([_eliminate_between_in_delete]), 113 exp.Flatten: rename_func("ARRAY_FLATTEN"), 114 exp.JSONExtractScalar: arrow_json_extract_sql, 115 exp.JSONExtract: arrow_json_extract_sql, 116 # Both MAP forms (two-array MAP([keys], [values]) and variadic MAP(k1, v1, ...)) 117 # generate StarRocks' variadic MAP(k1, v1, k2, v2, ...) constructor 118 exp.Map: lambda self, e: var_map_sql(self, e, "MAP"), 119 exp.Property: property_sql, 120 exp.RegexpLike: rename_func("REGEXP"), 121 # Inherited from MySQL, minus operations StarRocks supports natively 122 # (QUALIFY, FULL OUTER JOIN, SEMI/ANTI JOIN) 123 exp.Select: transforms.preprocess( 124 [ 125 transforms.eliminate_distinct_on, 126 transforms.unnest_generate_date_array_using_recursive_cte, 127 ] 128 ), 129 exp.SchemaCommentProperty: lambda self, e: self.naked_property(e), 130 exp.SqlSecurityProperty: lambda self, e: f"SECURITY {self.sql(e.this)}", 131 exp.StDistance: st_distance_sphere, 132 exp.StrToUnix: lambda self, e: self.func("UNIX_TIMESTAMP", e.this, self.format_time(e)), 133 exp.TimestampTrunc: lambda self, e: self.func( 134 "DATE_TRUNC", weekstart_unit_to_str(self, e), e.this 135 ), 136 exp.TimeStrToDate: rename_func("TO_DATE"), 137 exp.UnixToStr: lambda self, e: self.func("FROM_UNIXTIME", e.this, self.format_time(e)), 138 exp.UnixToTime: rename_func("FROM_UNIXTIME"), 139 exp.VarMap: lambda self, e: var_map_sql(self, e, "MAP"), 140 } 141 142 # https://docs.starrocks.io/docs/sql-reference/sql-statements/keywords/#reserved-keywords 143 RESERVED_KEYWORDS = { 144 "add", 145 "all", 146 "alter", 147 "analyze", 148 "and", 149 "array", 150 "as", 151 "asc", 152 "between", 153 "bigint", 154 "bitmap", 155 "both", 156 "by", 157 "case", 158 "char", 159 "character", 160 "check", 161 "collate", 162 "column", 163 "compaction", 164 "convert", 165 "create", 166 "cross", 167 "cube", 168 "current_date", 169 "current_role", 170 "current_time", 171 "current_timestamp", 172 "current_user", 173 "database", 174 "databases", 175 "decimal", 176 "decimalv2", 177 "decimal32", 178 "decimal64", 179 "decimal128", 180 "default", 181 "deferred", 182 "delete", 183 "dense_rank", 184 "desc", 185 "describe", 186 "distinct", 187 "double", 188 "drop", 189 "dual", 190 "else", 191 "except", 192 "exists", 193 "explain", 194 "false", 195 "first_value", 196 "float", 197 "for", 198 "force", 199 "from", 200 "full", 201 "function", 202 "grant", 203 "group", 204 "grouping", 205 "grouping_id", 206 "groups", 207 "having", 208 "hll", 209 "host", 210 "if", 211 "ignore", 212 "immediate", 213 "in", 214 "index", 215 "infile", 216 "inner", 217 "insert", 218 "int", 219 "integer", 220 "intersect", 221 "into", 222 "is", 223 "join", 224 "json", 225 "key", 226 "keys", 227 "kill", 228 "lag", 229 "largeint", 230 "last_value", 231 "lateral", 232 "lead", 233 "left", 234 "like", 235 "limit", 236 "load", 237 "localtime", 238 "localtimestamp", 239 "maxvalue", 240 "minus", 241 "mod", 242 "not", 243 "ntile", 244 "null", 245 "on", 246 "or", 247 "order", 248 "outer", 249 "outfile", 250 "over", 251 "partition", 252 "percentile", 253 "primary", 254 "procedure", 255 "qualify", 256 "range", 257 "rank", 258 "read", 259 "regexp", 260 "release", 261 "rename", 262 "replace", 263 "revoke", 264 "right", 265 "rlike", 266 "row", 267 "row_number", 268 "rows", 269 "schema", 270 "schemas", 271 "select", 272 "set", 273 "set_var", 274 "show", 275 "smallint", 276 "system", 277 "table", 278 "terminated", 279 "text", 280 "then", 281 "tinyint", 282 "to", 283 "true", 284 "union", 285 "unique", 286 "unsigned", 287 "update", 288 "use", 289 "using", 290 "values", 291 "varchar", 292 "when", 293 "where", 294 "with", 295 } 296 297 def ignorenulls_sql(self, expression: exp.IgnoreNulls) -> str: 298 # IGNORE NULLS follows the first argument, e.g. LAG(x IGNORE NULLS, 1, 0) 299 # https://docs.starrocks.io/docs/sql-reference/sql-functions/Window_function/ 300 func = expression.this 301 if isinstance(func, (exp.FirstValue, exp.LastValue, exp.Lag, exp.Lead)): 302 return self.func( 303 func.sql_name(), 304 Generator.ignorenulls_sql(self, exp.IgnoreNulls(this=func.this)), 305 func.args.get("offset"), 306 func.args.get("default"), 307 ) 308 309 return super().ignorenulls_sql(expression) 310 311 def respectnulls_sql(self, expression: exp.RespectNulls) -> str: 312 # RESPECT NULLS is the default behavior, and StarRocks rejects the keyword 313 return self.sql(expression, "this") 314 315 def create_sql(self, expression: exp.Create) -> str: 316 # Starrocks' primary key is defined outside of the schema, so we need to move it there 317 schema = expression.this 318 if isinstance(schema, exp.Schema): 319 primary_key = schema.find(exp.PrimaryKey) 320 321 if primary_key: 322 props = expression.args.get("properties") 323 324 if not props: 325 props = exp.Properties(expressions=[]) 326 expression.set("properties", props) 327 328 # Verify if the first one is an engine property. Is true then insert it after the engine, 329 # otherwise insert it at the beginning 330 engine = props.find(exp.EngineProperty) 331 engine_index = (engine.index or 0) if engine else -1 332 props.set("expressions", primary_key.pop(), engine_index + 1, overwrite=False) 333 334 return super().create_sql(expression) 335 336 def partitionedbyproperty_sql(self, expression: exp.PartitionedByProperty) -> str: 337 this = expression.this 338 if isinstance(this, exp.Schema): 339 # For MVs, StarRocks needs outer parentheses. 340 create = expression.find_ancestor(exp.Create) 341 342 sql = self.expressions(this, flat=True) 343 if (create and create.kind == "VIEW") or all( 344 isinstance(col, (exp.Column, exp.Identifier)) for col in this.expressions 345 ): 346 sql = f"({sql})" 347 348 return f"PARTITION BY {sql}" 349 350 return f"PARTITION BY {self.sql(this)}" 351 352 def clusterproperty_sql(self, expression: exp.ClusterProperty) -> str: 353 """Generate StarRocks ORDER BY clause for clustering.""" 354 if expression.this: 355 self.unsupported(f"Unsupported CLUSTER BY {self.sql(expression, 'this')}") 356 return "" 357 expressions = self.expressions(expression, flat=True) 358 return f"ORDER BY ({expressions})" 359 360 def refreshtriggerproperty_sql(self, expression: exp.RefreshTriggerProperty) -> str: 361 """Generate StarRocks REFRESH clause for materialized views. 362 There is a little difference of the syntax between StarRocks and Doris. 363 """ 364 method = self.sql(expression, "method") 365 method = f" {method}" if method else "" 366 kind = self.sql(expression, "kind") 367 kind = f" {kind}" if kind else "" 368 starts = self.sql(expression, "starts") 369 starts = f" START ({starts})" if starts else "" 370 every = self.sql(expression, "every") 371 unit = self.sql(expression, "unit") 372 every = f" EVERY (INTERVAL {every} {unit})" if every and unit else "" 373 374 return f"REFRESH{method}{kind}{starts}{every}"
Generator converts a given syntax tree to the corresponding SQL string.
Arguments:
- pretty: Whether to format the produced SQL string. Default: False.
- identify: Determines when an identifier should be quoted. Possible values are: False (default): Never quote, except in cases where it's mandatory by the dialect. True: Always quote except for specials cases. 'safe': Only quote identifiers that are case insensitive.
- normalize: Whether to normalize identifiers to lowercase. Default: False.
- pad: The pad size in a formatted string. For example, this affects the indentation of a projection in a query, relative to its nesting level. Default: 2.
- indent: The indentation size in a formatted string. For example, this affects the
indentation of subqueries and filters under a
WHEREclause. Default: 2. - normalize_functions: How to normalize function names. Possible values are: "upper" or True (default): Convert names to uppercase. "lower": Convert names to lowercase. False: Disables function name normalization.
- unsupported_level: Determines the generator's behavior when it encounters unsupported expressions. Default ErrorLevel.WARN.
- max_unsupported: Maximum number of unsupported messages to include in a raised UnsupportedError. This is only relevant if unsupported_level is ErrorLevel.RAISE. Default: 3
- leading_comma: Whether the comma is leading or trailing in select expressions. This is only relevant when generating in pretty mode. Default: False
- max_text_width: The max number of characters in a segment before creating new lines in pretty mode. The default is on the smaller end because the length only represents a segment and not the true line length. Default: 80
- comments: Whether to preserve comments in the output SQL code. Default: True
TYPE_MAPPING =
{<DType.NCHAR: 'NCHAR'>: 'CHAR', <DType.NVARCHAR: 'NVARCHAR'>: 'VARCHAR', <DType.INET: 'INET'>: 'INET', <DType.ROWVERSION: 'ROWVERSION'>: 'VARBINARY', <DType.UBIGINT: 'UBIGINT'>: 'BIGINT', <DType.UINT: 'UINT'>: 'INT', <DType.UMEDIUMINT: 'UMEDIUMINT'>: 'MEDIUMINT', <DType.USMALLINT: 'USMALLINT'>: 'SMALLINT', <DType.UTINYINT: 'UTINYINT'>: 'TINYINT', <DType.UDECIMAL: 'UDECIMAL'>: 'DECIMAL', <DType.UDOUBLE: 'UDOUBLE'>: 'DOUBLE', <DType.DATETIME2: 'DATETIME2'>: 'DATETIME', <DType.SMALLDATETIME: 'SMALLDATETIME'>: 'DATETIME', <DType.TIMESTAMP: 'TIMESTAMP'>: 'DATETIME', <DType.TIMESTAMPNTZ: 'TIMESTAMPNTZ'>: 'DATETIME', <DType.TIMESTAMPTZ: 'TIMESTAMPTZ'>: 'DATETIME', <DType.TIMESTAMPLTZ: 'TIMESTAMPLTZ'>: 'TIMESTAMP', <DType.INT128: 'INT128'>: 'LARGEINT', <DType.TEXT: 'TEXT'>: 'STRING'}
PROPERTIES_LOCATION =
{<class 'sqlglot.expressions.properties.AllowedValuesProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.AlgorithmProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.ApiProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.ApplicationProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.AutoIncrementProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.AutoRefreshProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.BackupProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.BlockCompressionProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.CalledOnNullInputProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.CatalogProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.CharacterSetProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ChecksumProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.CollateProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ComputeProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.CopyGrantsProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.query.Cluster'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ClusteredByProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ClusterProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DistributedByProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DuplicateKeyProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DataBlocksizeProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.DatabaseProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.DataDeletionProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DefinerProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.DictRange'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DictProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DynamicProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.DistKeyProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.DistStyleProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.EmptyProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.EncodeProperty'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.properties.EngineProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.EnviromentProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.HandlerProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ParameterStyleProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ExecuteAsProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ExternalProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.FallbackProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.FileFormatProperty'>: <PropertiesLocation.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.properties.FreespaceProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.GlobalProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.HeapProperty'>: <PropertiesLocation.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.properties.HybridProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.InheritsProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.IcebergProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.IncludeProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.InputModelProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.IsolatedLoadingProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.JournalProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.LanguageProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.LikeProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.LocationProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.LockProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.LockingProperty'>: <PropertiesLocation.POST_ALIAS: 'POST_ALIAS'>, <class 'sqlglot.expressions.properties.LogProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.MaskingProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.MaterializedProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.MergeBlockRatioProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.ModuleProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.NetworkProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.NoPrimaryIndexProperty'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.properties.OnProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.OnCommitProperty'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.query.Order'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.OutputModelProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.PartitionedByProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.PartitionedOfProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.constraints.PrimaryKey'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.Property'>: <PropertiesLocation.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.properties.RefreshTriggerProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.RemoteWithConnectionModelProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ReturnsProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.RollupProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.RowAccessProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.RowFormatProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.RowFormatDelimitedProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.RowFormatSerdeProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SampleProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SchemaCommentProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SecureProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.SecurityIntegrationProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.SerdeProperties'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ddl.Set'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SettingsProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SetProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.SetConfigProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SharingProperty'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.ddl.SequenceProperties'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.ddl.TriggerProperties'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.properties.SortKeyProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SqlReadWriteProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.SqlSecurityProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.StabilityProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.StorageHandlerProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.StreamingTableProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.StrictProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.Tags'>: <PropertiesLocation.POST_WITH: 'POST_WITH'>, <class 'sqlglot.expressions.properties.TemporaryProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.ToTableProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.TransientProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.TransformModelProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.ddl.MergeTreeTTL'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.UnloggedProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.UsingProperty'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.properties.UsingTemplateProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ViewAttributeProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.VirtualProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.VolatileProperty'>: <PropertiesLocation.UNSUPPORTED: 'UNSUPPORTED'>, <class 'sqlglot.expressions.properties.WithDataProperty'>: <PropertiesLocation.POST_EXPRESSION: 'POST_EXPRESSION'>, <class 'sqlglot.expressions.properties.WithJournalTableProperty'>: <PropertiesLocation.POST_NAME: 'POST_NAME'>, <class 'sqlglot.expressions.properties.WithProcedureOptions'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.WithSchemaBindingProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.WithSystemVersioningProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.ForceProperty'>: <PropertiesLocation.POST_CREATE: 'POST_CREATE'>, <class 'sqlglot.expressions.properties.PartitionByRangeProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.PartitionByListProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>, <class 'sqlglot.expressions.properties.UniqueKeyProperty'>: <PropertiesLocation.POST_SCHEMA: 'POST_SCHEMA'>}
TRANSFORMS =
{<class 'sqlglot.expressions.query.JSONPathFilter'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathKey'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathRecursive'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathRoot'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathScript'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathSelector'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathSlice'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathSubscript'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathUnion'>: <function <lambda>>, <class 'sqlglot.expressions.query.JSONPathWildcard'>: <function <lambda>>, <class 'sqlglot.expressions.core.Adjacent'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.AllowedValuesProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.AnalyzeColumns'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.AnalyzeWith'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.ArrayContainedBy'>: <function StarRocksGenerator.<lambda>>, <class 'sqlglot.expressions.array.ArrayContainsAll'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.array.ArrayOverlaps'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.AssumeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.AutoRefreshProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.BackupProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.BinaryColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.CaseSpecificColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CalledOnNullInputProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.math.Ceil'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.CharacterSetColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CharacterSetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.ClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.CollateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.CommentColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.ConnectByRoot'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.string.ConvertToCharset'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CopyGrantsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CredentialsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.CurrentCatalog'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.SessionUser'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.constraints.DateFormatColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.DefaultColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ApiProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ApplicationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.CatalogProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ComputeProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.DatabaseProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.DynamicProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.EmptyProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.EncodeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.EndStatement'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.EnviromentProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.HandlerProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ParameterStyleProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.EphemeralColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.ExcludeColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ExecuteAsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Except'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ExternalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.math.Floor'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Get'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.GlobalProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.HeapProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.HybridProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.IcebergProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.InheritsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.InlineLengthColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.InputModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Intersect'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.datatypes.IntervalSpan'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.Int64'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONBContainsAnyTopKeys'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONBContainsAllTopKeys'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONBContainsTopKey'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONBDeleteAtPath'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONBPathExists'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONObject'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.json.JSONObjectAgg'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.LanguageProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.LocationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.LogProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.MaskingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.MaterializedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.functions.NetFunc'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.NetworkProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.NonClusteredColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.NoPrimaryIndexProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.NotForReplicationColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.OnCommitProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.OnProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.OnUpdateColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.Operator'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.OutputModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.ExtendsLeft'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.ExtendsRight'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.PathColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.PartitionedByBucket'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.PartitionByTruncate'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.PivotAny'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.PositionalColumn'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.ProjectionPolicyColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.InvisibleColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.ZeroFillColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Put'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.RemoteWithConnectionModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ReturnsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.RowAccessProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.core.SafeFunc'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SampleProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SecureProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SecurityIntegrationProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SetConfigProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SetProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SettingsProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SharingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SqlReadWriteProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.SqlSecurityProperty'>: <function StarRocksGenerator.<lambda>>, <class 'sqlglot.expressions.properties.StabilityProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Stream'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.StreamingTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.StrictProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ddl.SwapTable'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.TableColumn'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.Tags'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.TemporaryProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.TitleColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.ToMap'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ToTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.TransformModelProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.TransientProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.VirtualProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.ddl.TriggerExecute'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.Union'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.UnloggedProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.UsingTemplateProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.query.UsingData'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.UppercaseColumnConstraint'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.temporal.UtcDate'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.temporal.UtcTime'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.UtcTimestamp'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.query.Variadic'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.array.VarMap'>: <function StarRocksGenerator.<lambda>>, <class 'sqlglot.expressions.properties.ViewAttributeProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.VolatileProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithJournalTableProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithProcedureOptions'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.WithSchemaBindingProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.constraints.WithOperator'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.properties.ForceProperty'>: <function Generator.<lambda>>, <class 'sqlglot.expressions.aggregate.ArrayAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.math.BitwiseAndAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.math.BitwiseOrAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.math.BitwiseXorAgg'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.math.BitwiseCount'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.string.Chr'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.CurrentDate'>: <function no_paren_current_date_sql>, <class 'sqlglot.expressions.functions.CurrentVersion'>: <function StarRocksGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.DateDiff'>: <function StarRocksGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.DateAdd'>: <function date_add_sql.<locals>.func>, <class 'sqlglot.expressions.temporal.DateStrToDate'>: <function datestrtodate_sql>, <class 'sqlglot.expressions.temporal.DateSub'>: <function date_add_sql.<locals>.func>, <class 'sqlglot.expressions.temporal.Day'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.temporal.DayOfMonth'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.temporal.DayOfWeek'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.temporal.DayOfYear'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.aggregate.GroupConcat'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.core.ILike'>: <function no_ilike_sql>, <class 'sqlglot.expressions.functions.If'>: <function if_sql.<locals>._if_sql>, <class 'sqlglot.expressions.json.JSONExtractScalar'>: <function arrow_json_extract_sql>, <class 'sqlglot.expressions.string.Length'>: <function length_or_char_length_sql>, <class 'sqlglot.expressions.aggregate.LogicalOr'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.LogicalAnd'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.Max'>: <function max_or_greatest>, <class 'sqlglot.expressions.aggregate.Min'>: <function min_or_least>, <class 'sqlglot.expressions.temporal.Month'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.core.NullSafeEQ'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.core.NullSafeNEQ'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.string.NumberToStr'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.query.Pivot'>: <function no_pivot_sql>, <class 'sqlglot.expressions.query.Select'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.string.StrPosition'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.StrToDate'>: <function _str_to_date_sql>, <class 'sqlglot.expressions.temporal.StrToTime'>: <function _str_to_date_sql>, <class 'sqlglot.expressions.string.Stuff'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.query.TableSample'>: <function no_tablesample_sql>, <class 'sqlglot.expressions.temporal.TimeFromParts'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TimestampAdd'>: <function date_add_interval_sql.<locals>.func>, <class 'sqlglot.expressions.temporal.TimestampDiff'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TimestampSub'>: <function date_add_interval_sql.<locals>.func>, <class 'sqlglot.expressions.temporal.TimeStrToUnix'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.TimeStrToTime'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TimeToStr'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.math.Trunc'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.functions.TryCast'>: <function no_trycast_sql>, <class 'sqlglot.expressions.temporal.TsOrDsAdd'>: <function date_add_sql.<locals>.func>, <class 'sqlglot.expressions.temporal.TsOrDsDiff'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TsOrDsToDate'>: <function _ts_or_ds_to_date_sql>, <class 'sqlglot.expressions.string.Unicode'>: <function MySQLGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.UnixToTime'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.Week'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.temporal.WeekOfYear'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.temporal.Year'>: <function remove_ts_or_ds_to_date.<locals>.func>, <class 'sqlglot.expressions.aggregate.ArgMax'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.aggregate.ArgMin'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.array.Array'>: <function inline_array_sql>, <class 'sqlglot.expressions.array.ArrayFilter'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.array.ArrayToString'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.core.ApproxDistinct'>: <function approx_count_distinct_sql>, <class 'sqlglot.expressions.dml.Delete'>: <function preprocess.<locals>._to_sql>, <class 'sqlglot.expressions.array.Flatten'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.json.JSONExtract'>: <function arrow_json_extract_sql>, <class 'sqlglot.expressions.array.Map'>: <function StarRocksGenerator.<lambda>>, <class 'sqlglot.expressions.properties.Property'>: <function property_sql>, <class 'sqlglot.expressions.core.RegexpLike'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.properties.SchemaCommentProperty'>: <function StarRocksGenerator.<lambda>>, <class 'sqlglot.expressions.array.StDistance'>: <function st_distance_sphere>, <class 'sqlglot.expressions.temporal.StrToUnix'>: <function StarRocksGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TimestampTrunc'>: <function StarRocksGenerator.<lambda>>, <class 'sqlglot.expressions.temporal.TimeStrToDate'>: <function rename_func.<locals>.<lambda>>, <class 'sqlglot.expressions.temporal.UnixToStr'>: <function StarRocksGenerator.<lambda>>}
RESERVED_KEYWORDS =
{'else', 'asc', 'and', 'collate', 'lag', 'from', 'current_timestamp', 'inner', 'databases', 'maxvalue', 'decimal32', 'to', 'array', 'first_value', 'exists', 'integer', 'decimal64', 'values', 'for', 'localtime', 'using', 'delete', 'except', 'infile', 'decimalv2', 'where', 'rows', 'or', 'database', 'unique', 'if', 'text', 'grouping', 'left', 'set_var', 'qualify', 'ntile', 'order', 'both', 'limit', 'having', 'char', 'join', 'key', 'like', 'smallint', 'table', 'index', 'procedure', 'set', 'lead', 'kill', 'desc', 'hll', 'primary', 'then', 'double', 'case', 'not', 'check', 'row', 'grant', 'decimal', 'float', 'full', 'terminated', 'outfile', 'character', 'int', 'ignore', 'rank', 'varchar', 'group', 'release', 'keys', 'alter', 'over', 'current_time', 'regexp', 'create', 'bitmap', 'row_number', 'partition', 'select', 'localtimestamp', 'add', 'distinct', 'into', 'load', 'rename', 'dense_rank', 'right', 'force', 'groups', 'read', 'insert', 'between', 'describe', 'schemas', 'decimal128', 'false', 'intersect', 'revoke', 'grouping_id', 'update', 'tinyint', 'system', 'last_value', 'dual', 'percentile', 'in', 'use', 'when', 'convert', 'json', 'outer', 'rlike', 'host', 'default', 'schema', 'lateral', 'replace', 'current_user', 'mod', 'unsigned', 'explain', 'with', 'cross', 'current_date', 'current_role', 'by', 'deferred', 'minus', 'true', 'is', 'union', 'column', 'on', 'as', 'null', 'all', 'bigint', 'range', 'show', 'drop', 'function', 'compaction', 'immediate', 'largeint', 'cube', 'analyze'}
297 def ignorenulls_sql(self, expression: exp.IgnoreNulls) -> str: 298 # IGNORE NULLS follows the first argument, e.g. LAG(x IGNORE NULLS, 1, 0) 299 # https://docs.starrocks.io/docs/sql-reference/sql-functions/Window_function/ 300 func = expression.this 301 if isinstance(func, (exp.FirstValue, exp.LastValue, exp.Lag, exp.Lead)): 302 return self.func( 303 func.sql_name(), 304 Generator.ignorenulls_sql(self, exp.IgnoreNulls(this=func.this)), 305 func.args.get("offset"), 306 func.args.get("default"), 307 ) 308 309 return super().ignorenulls_sql(expression)
315 def create_sql(self, expression: exp.Create) -> str: 316 # Starrocks' primary key is defined outside of the schema, so we need to move it there 317 schema = expression.this 318 if isinstance(schema, exp.Schema): 319 primary_key = schema.find(exp.PrimaryKey) 320 321 if primary_key: 322 props = expression.args.get("properties") 323 324 if not props: 325 props = exp.Properties(expressions=[]) 326 expression.set("properties", props) 327 328 # Verify if the first one is an engine property. Is true then insert it after the engine, 329 # otherwise insert it at the beginning 330 engine = props.find(exp.EngineProperty) 331 engine_index = (engine.index or 0) if engine else -1 332 props.set("expressions", primary_key.pop(), engine_index + 1, overwrite=False) 333 334 return super().create_sql(expression)
def
partitionedbyproperty_sql( self, expression: sqlglot.expressions.properties.PartitionedByProperty) -> str:
336 def partitionedbyproperty_sql(self, expression: exp.PartitionedByProperty) -> str: 337 this = expression.this 338 if isinstance(this, exp.Schema): 339 # For MVs, StarRocks needs outer parentheses. 340 create = expression.find_ancestor(exp.Create) 341 342 sql = self.expressions(this, flat=True) 343 if (create and create.kind == "VIEW") or all( 344 isinstance(col, (exp.Column, exp.Identifier)) for col in this.expressions 345 ): 346 sql = f"({sql})" 347 348 return f"PARTITION BY {sql}" 349 350 return f"PARTITION BY {self.sql(this)}"
352 def clusterproperty_sql(self, expression: exp.ClusterProperty) -> str: 353 """Generate StarRocks ORDER BY clause for clustering.""" 354 if expression.this: 355 self.unsupported(f"Unsupported CLUSTER BY {self.sql(expression, 'this')}") 356 return "" 357 expressions = self.expressions(expression, flat=True) 358 return f"ORDER BY ({expressions})"
Generate StarRocks ORDER BY clause for clustering.
def
refreshtriggerproperty_sql( self, expression: sqlglot.expressions.properties.RefreshTriggerProperty) -> str:
360 def refreshtriggerproperty_sql(self, expression: exp.RefreshTriggerProperty) -> str: 361 """Generate StarRocks REFRESH clause for materialized views. 362 There is a little difference of the syntax between StarRocks and Doris. 363 """ 364 method = self.sql(expression, "method") 365 method = f" {method}" if method else "" 366 kind = self.sql(expression, "kind") 367 kind = f" {kind}" if kind else "" 368 starts = self.sql(expression, "starts") 369 starts = f" START ({starts})" if starts else "" 370 every = self.sql(expression, "every") 371 unit = self.sql(expression, "unit") 372 every = f" EVERY (INTERVAL {every} {unit})" if every and unit else "" 373 374 return f"REFRESH{method}{kind}{starts}{every}"
Generate StarRocks REFRESH clause for materialized views. There is a little difference of the syntax between StarRocks and Doris.
Inherited Members
- sqlglot.generator.Generator
- Generator
- WINDOW_FUNCS_WITH_NULL_ORDERING
- IGNORE_NULLS_IN_FUNC
- IGNORE_NULLS_BEFORE_ORDER
- CREATE_FUNCTION_RETURN_AS
- MATCHED_BY_SOURCE
- SUPPORTS_MERGE_WHERE
- SINGLE_STRING_INTERVAL
- AUTO_REFRESH_BARE_INTERVALS
- GROUPINGS_SEP
- SUPPORTS_GROUPING_SETS_AS_SUFFIX
- INDEX_ON
- INOUT_SEPARATOR
- DIRECTED_JOINS
- QUERY_HINTS
- LIMIT_IS_TOP
- RETURNING_END
- EXTRACT_ALLOWS_QUOTES
- TZ_TO_WITH_TIME_ZONE
- ALTER_TABLE_INCLUDE_COLUMN_KEYWORD
- UNNEST_WITH_ORDINALITY
- SEMI_ANTI_JOIN_WITH_SIDE
- COMPUTED_COLUMN_WITH_TYPE
- SUPPORTS_TABLE_COPY
- TABLESAMPLE_REQUIRES_PARENS
- TABLESAMPLE_SIZE_IS_ROWS
- TABLESAMPLE_KEYWORDS
- TABLESAMPLE_WITH_METHOD
- TABLESAMPLE_SEED_KEYWORD
- HISTORICAL_DATA_POST_ALIAS
- COLLATE_IS_FUNC
- DATA_TYPE_SPECIFIERS_ALLOWED
- ENSURE_BOOLS
- CTE_RECURSIVE_KEYWORD_REQUIRED
- SUPPORTS_SINGLE_ARG_CONCAT
- SUPPORTS_TABLE_ALIAS_COLUMNS
- SUPPORTS_NAMED_CTE_COLUMNS
- UNPIVOT_ALIASES_ARE_IDENTIFIERS
- PIVOT_ALIAS_WITH_AS
- SUPPORTS_SELECT_INTO
- SUPPORTS_UNLOGGED_TABLES
- SUPPORTS_CREATE_TABLE_LIKE
- SUPPORTS_ALTER_COLUMN_IF_EXISTS
- LIKE_PROPERTY_INSIDE_SCHEMA
- MULTI_ARG_DISTINCT
- JSON_PATH_SINGLE_QUOTE_ESCAPE
- JSON_PATH_KEY_QUOTED_FORCES_BRACKETS
- SUPPORTED_JSON_PATH_PARTS
- CAN_IMPLEMENT_ARRAY_ANY
- SUPPORTS_WINDOW_EXCLUDE
- SET_OP_MODIFIERS
- SET_OP_LIMITS
- SET_OP_PARENTHESIZED_OPERANDS
- COPY_PARAMS_ARE_WRAPPED
- COPY_PARAMS_EQ_REQUIRED
- COPY_HAS_INTO_KEYWORD
- UNICODE_SUBSTITUTE
- STAR_EXCEPT
- HEX_FUNC
- QUOTE_JSON_PATH
- SUPPORTS_EXPLODING_PROJECTIONS
- ARRAY_CONCAT_IS_VAR_LEN
- SUPPORTS_CONVERT_TIMEZONE
- SUPPORTS_UNIX_SECONDS
- ALTER_SET_WRAPPED
- NORMALIZE_EXTRACT_DATE_PARTS
- ARRAY_SIZE_NAME
- ALTER_SET_TYPE
- ARRAY_SIZE_DIM_REQUIRED
- SUPPORTS_BETWEEN_FLAGS
- SUPPORTS_LIKE_QUANTIFIERS
- MATCH_AGAINST_TABLE_PREFIX
- SET_ASSIGNMENT_REQUIRES_VARIABLE_KEYWORD
- DECLARE_DEFAULT_ASSIGNMENT
- STAR_EXCLUDE_REQUIRES_DERIVED_TABLE
- SUPPORTS_DROP_ALTER_ICEBERG_PROPERTY
- UNSUPPORTED_TYPES
- TYPE_PARAM_SETTINGS
- TIME_PART_SINGULARS
- TOKEN_MAPPING
- STRUCT_DELIMITER
- PARAMETER_TOKEN
- NAMED_PLACEHOLDER_TOKEN
- EXPRESSION_PRECEDES_PROPERTIES_CREATABLES
- WITH_SEPARATED_COMMENTS
- EXCLUDE_COMMENTS
- UNWRAPPED_INTERVAL_VALUES
- PARAMETERIZABLE_TEXT_TYPES
- EXPRESSIONS_WITHOUT_NESTED_CTES
- RESPECT_IGNORE_NULLS_UNSUPPORTED_EXPRESSIONS
- MOD_OPERATOR
- MOD_PAREN_PARENT_TYPES
- SAFE_JSON_PATH_KEY_RE
- SENTINEL_LINE_BREAK
- pretty
- identify
- normalize
- pad
- unsupported_level
- max_unsupported
- leading_comma
- max_text_width
- comments
- dialect
- normalize_functions
- unsupported_messages
- generate
- preprocess
- unsupported
- sep
- seg
- sanitize_comment
- maybe_comment
- wrap
- no_identify
- normalize_func
- indent
- sql
- uncache_sql
- cache_sql
- characterset_sql
- column_parts
- column_sql
- pseudocolumn_sql
- columnposition_sql
- columndef_sql
- columnconstraint_sql
- autoincrementcolumnconstraint_sql
- compresscolumnconstraint_sql
- generatedasidentitycolumnconstraint_sql
- generatedasrowcolumnconstraint_sql
- periodforsystemtimeconstraint_sql
- notnullcolumnconstraint_sql
- primarykeycolumnconstraint_sql
- uniquecolumnconstraint_sql
- inoutcolumnconstraint_sql
- createable_sql
- sequenceproperties_sql
- triggerproperties_sql
- triggerreferencing_sql
- triggerevent_sql
- clone_sql
- describe_sql
- heredoc_sql
- prepend_ctes
- with_sql
- cte_sql
- tablealias_sql
- bitstring_sql
- hexstring_sql
- bytestring_sql
- unicodestring_sql
- rawstring_sql
- datatypeparam_sql
- datatype_param_bound_limiter
- directory_sql
- delete_sql
- drop_sql
- set_operation
- set_operations
- fetch_sql
- limitoptions_sql
- filter_sql
- hint_sql
- indexparameters_sql
- index_sql
- dynamicidentifier_sql
- identifier_sql
- hex_sql
- lowerhex_sql
- inputoutputformat_sql
- national_sql
- properties_sql
- root_properties
- properties
- with_properties
- property_name
- property_sql
- uuidproperty_sql
- likeproperty_sql
- fallbackproperty_sql
- journalproperty_sql
- freespaceproperty_sql
- checksumproperty_sql
- mergeblockratioproperty_sql
- moduleproperty_sql
- datablocksizeproperty_sql
- blockcompressionproperty_sql
- isolatedloadingproperty_sql
- partitionboundspec_sql
- partitionedofproperty_sql
- lockingproperty_sql
- withdataproperty_sql
- withsystemversioningproperty_sql
- insert_sql
- introducer_sql
- kill_sql
- pseudotype_sql
- objectidentifier_sql
- onconflict_sql
- returning_sql
- rowformatdelimitedproperty_sql
- withtablehint_sql
- indextablehint_sql
- historicaldata_sql
- table_parts
- table_sql
- tablefromrows_sql
- tablesample_sql
- pivot_sql
- version_sql
- tuple_sql
- update_sql
- values_sql
- var_sql
- into_sql
- from_sql
- groupingsets_sql
- rollup_sql
- rollupindex_sql
- rollupproperty_sql
- cube_sql
- group_sql
- having_sql
- connect_sql
- prior_sql
- join_sql
- lambda_sql
- lateral_op
- lateral_sql
- limit_sql
- offset_sql
- setitem_sql
- set_sql
- queryband_sql
- pragma_sql
- lock_sql
- literal_sql
- escape_str
- loaddata_sql
- null_sql
- boolean_sql
- booland_sql
- boolor_sql
- order_sql
- withfill_sql
- cluster_sql
- distribute_sql
- sort_sql
- ordered_sql
- matchrecognizemeasure_sql
- matchrecognize_sql
- query_modifiers
- options_modifier
- forclause_sql
- queryoption_sql
- offset_limit_modifiers
- after_limit_modifiers
- select_sql
- schema_sql
- schema_columns_sql
- star_sql
- parameter_sql
- sessionparameter_sql
- placeholder_sql
- subquery_sql
- qualify_sql
- unnest_sql
- prewhere_sql
- where_sql
- window_sql
- partition_by_sql
- windowspec_sql
- withingroup_sql
- between_sql
- bracket_offset_expressions
- bracket_sql
- all_sql
- any_sql
- exists_sql
- case_sql
- constraint_sql
- nextvaluefor_sql
- trim_sql
- convert_concat_args
- concat_sql
- concatws_sql
- check_sql
- foreignkey_sql
- primarykey_sql
- timeserieskey_sql
- if_sql
- matchagainst_sql
- jsonkeyvalue_sql
- jsonpath_sql
- json_path_part
- formatjson_sql
- formatphrase_sql
- jsonarray_sql
- jsonarrayagg_sql
- jsoncolumndef_sql
- jsonschema_sql
- jsontable_sql
- openjsoncolumndef_sql
- openjson_sql
- in_sql
- in_unnest_op
- interval_sql
- return_sql
- reference_sql
- anonymous_sql
- paren_sql
- neg_sql
- not_sql
- alias_sql
- pivotalias_sql
- aliases_sql
- atindex_sql
- fromtimezone_sql
- fromiso8601date_sql
- fromiso8601timestamp_sql
- fromiso8601timestampnanos_sql
- add_sql
- and_sql
- or_sql
- xor_sql
- connector_sql
- bitwiseand_sql
- bitwiseleftshift_sql
- bitwisenot_sql
- bitwiseor_sql
- bitwiserightshift_sql
- bitwisexor_sql
- strtotime_sql
- strtodate_sql
- parsedatetime_sql
- currentdate_sql
- collate_sql
- command_sql
- comment_sql
- mergetreettlaction_sql
- mergetreettl_sql
- transaction_sql
- commit_sql
- rollback_sql
- modifycolumn_sql
- alterindex_sql
- alterdiststyle_sql
- altersortkey_sql
- renamecolumn_sql
- alterset_sql
- alter_sql
- altersession_sql
- add_column_sql
- droppartition_sql
- dropprimarykey_sql
- addconstraint_sql
- addpartition_sql
- distinct_sql
- havingmax_sql
- intdiv_sql
- div_sql
- safedivide_sql
- overlaps_sql
- distance_sql
- distancend_sql
- dot_sql
- eq_sql
- propertyeq_sql
- escape_sql
- glob_sql
- gt_sql
- gte_sql
- is_sql
- like_sql
- ilike_sql
- match_sql
- similarto_sql
- lt_sql
- lte_sql
- mod_sql
- mul_sql
- neq_sql
- nullsafeeq_sql
- nullsafeneq_sql
- sub_sql
- trycast_sql
- jsoncast_sql
- try_sql
- log_sql
- use_sql
- binary
- ceil_floor
- function_fallback_sql
- func
- format_args
- too_wide
- format_time
- expressions
- op_expressions
- naked_property
- tag_sql
- token_sql
- userdefinedfunction_sql
- macrooverloads_sql
- macrooverload_sql
- joinhint_sql
- kwarg_sql
- when_sql
- whens_sql
- merge_sql
- tochar_sql
- tonumber_sql
- dictproperty_sql
- dictrange_sql
- dictsubproperty_sql
- duplicatekeyproperty_sql
- uniquekeyproperty_sql
- distributedbyproperty_sql
- oncluster_sql
- clusteredbyproperty_sql
- anyvalue_sql
- querytransform_sql
- indexconstraintoption_sql
- checkcolumnconstraint_sql
- indexcolumnconstraint_sql
- nvl2_sql
- nthvalue_sql
- comprehension_sql
- columnprefix_sql
- opclass_sql
- predict_sql
- generateembedding_sql
- generatetext_sql
- generatetable_sql
- generatebool_sql
- generateint_sql
- generatedouble_sql
- mltranslate_sql
- mlforecast_sql
- aiforecast_sql
- featuresattime_sql
- vectorsearch_sql
- forin_sql
- refresh_sql
- toarray_sql
- tsordstotime_sql
- tsordstotimestamp_sql
- tsordstodatetime_sql
- tsordstodate_sql
- unixdate_sql
- lastday_sql
- dateadd_sql
- arrayinsert_sql
- arrayany_sql
- struct_sql
- truncatetable_sql
- convert_sql
- copyparameter_sql
- credentials_sql
- copy_sql
- semicolon_sql
- datadeletionproperty_sql
- maskingpolicycolumnconstraint_sql
- gapfill_sql
- scope_resolution
- scoperesolution_sql
- parsejson_sql
- rand_sql
- changes_sql
- pad_sql
- summarize_sql
- explodinggenerateseries_sql
- json_sql
- jsonvalue_sql
- skipjsoncolumn_sql
- conditionalinsert_sql
- multitableinserts_sql
- oncondition_sql
- jsonextractquote_sql
- jsonexists_sql
- arrayagg_sql
- slice_sql
- apply_sql
- grant_sql
- revoke_sql
- grantprivilege_sql
- grantprincipal_sql
- columns_sql
- overlay_sql
- todouble_sql
- string_sql
- median_sql
- overflowtruncatebehavior_sql
- unixseconds_sql
- arraysize_sql
- attach_sql
- detach_sql
- attachoption_sql
- watermarkcolumnconstraint_sql
- encodeproperty_sql
- includeproperty_sql
- xmlelement_sql
- xmlkeyvalueoption_sql
- partitionbyrangepropertydynamic_sql
- unpivotcolumns_sql
- analyzesample_sql
- analyzestatistics_sql
- analyzehistogram_sql
- analyzedelete_sql
- analyzelistchainedrows_sql
- analyzevalidate_sql
- analyze_sql
- xmltable_sql
- xmlnamespace_sql
- export_sql
- declare_sql
- declareitem_sql
- recursivewithsearch_sql
- parameterizedagg_sql
- anonymousaggfunc_sql
- combinedaggfunc_sql
- combinedparameterizedagg_sql
- install_sql
- get_put_sql
- translatecharacters_sql
- decodecase_sql
- semanticview_sql
- getextract_sql
- datefromunixdate_sql
- space_sql
- buildproperty_sql
- modelattribute_sql
- directorystage_sql
- uuid_sql
- initcap_sql
- localtime_sql
- localtimestamp_sql
- weekstart_name
- weekstart_sql
- chr_sql
- block_sql
- functionspecification_sql
- storedprocedure_sql
- ifblock_sql
- casestatement_sql
- whileblock_sql
- loopblock_sql
- repeatblock_sql
- leave_sql
- iterate_sql
- execute_sql
- executesql_sql
- altermodifysqlsecurity_sql
- usingproperty_sql
- renameindex_sql
- sqlglot.generators.mysql.MySQLGenerator
- SELECT_KINDS
- TRY_SUPPORTED
- SUPPORTS_UESCAPE
- SUPPORTS_DECODE_CASE
- SUPPORTS_MODIFY_COLUMN
- SUPPORTS_CHANGE_COLUMN
- SUPPORTS_ALTER_COLUMN_NULLABILITY
- AFTER_HAVING_MODIFIER_TRANSFORMS
- INTERVAL_ALLOWS_PLURAL_FORM
- LOCKING_READS_SUPPORTED
- NULL_ORDERING_SUPPORTED
- JOIN_HINTS
- TABLE_HINTS
- DUPLICATE_KEY_UPDATE_WITH_SET
- QUERY_HINT_SEP
- VALUES_AS_TABLE
- NVL2_SUPPORTED
- LAST_DAY_SUPPORTS_DATE_PART
- JSON_PATH_BRACKETED_KEY_SUPPORTED
- JSON_KEY_VALUE_PAIR_SEP
- SUPPORTS_TO_NUMBER
- PAD_FILL_PATTERN_IS_REQUIRED
- WRAP_DERIVED_VALUES
- SUPPORTS_MEDIAN
- UNSIGNED_TYPE_MAPPING
- TIMESTAMP_TYPE_MAPPING
- LIMIT_FETCH
- LIMIT_ONLY_LITERALS
- CHAR_CAST_MAPPING
- SIGNED_CAST_MAPPING
- TIMESTAMP_FUNC_TYPES
- makeinterval_sql
- locate_properties
- computedcolumnconstraint_sql
- array_sql
- arraycontainsall_sql
- arraycontainedby_sql
- dpipe_sql
- extract_sql
- datatype_sql
- jsonarraycontains_sql
- cast_sql
- show_sql
- alterrename_sql
- altercolumn_sql
- timestamptrunc_sql
- converttimezone_sql
- attimezone_sql
- isascii_sql
- currentschema_sql
- partition_sql
- partitionbyrangeproperty_sql
- partitionbylistproperty_sql
- partitionlist_sql
- partitionrange_sql