summaryrefslogtreecommitdiffstats
path: root/sqlglot/generator.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlglot/generator.py')
-rw-r--r--sqlglot/generator.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/sqlglot/generator.py b/sqlglot/generator.py
index 7a2879c..b7e26bb 100644
--- a/sqlglot/generator.py
+++ b/sqlglot/generator.py
@@ -1226,9 +1226,10 @@ class Generator:
kind = expression.args.get("kind")
this = f" {self.sql(expression, 'this')}" if expression.this else ""
for_or_in = expression.args.get("for_or_in")
+ for_or_in = f" {for_or_in}" if for_or_in else ""
lock_type = expression.args.get("lock_type")
override = " OVERRIDE" if expression.args.get("override") else ""
- return f"LOCKING {kind}{this} {for_or_in} {lock_type}{override}"
+ return f"LOCKING {kind}{this}{for_or_in} {lock_type}{override}"
def withdataproperty_sql(self, expression: exp.WithDataProperty) -> str:
data_sql = f"WITH {'NO ' if expression.args.get('no') else ''}DATA"
@@ -2179,13 +2180,21 @@ class Generator:
)
def jsoncolumndef_sql(self, expression: exp.JSONColumnDef) -> str:
+ path = self.sql(expression, "path")
+ path = f" PATH {path}" if path else ""
+ nested_schema = self.sql(expression, "nested_schema")
+
+ if nested_schema:
+ return f"NESTED{path} {nested_schema}"
+
this = self.sql(expression, "this")
kind = self.sql(expression, "kind")
kind = f" {kind}" if kind else ""
- path = self.sql(expression, "path")
- path = f" PATH {path}" if path else ""
return f"{this}{kind}{path}"
+ def jsonschema_sql(self, expression: exp.JSONSchema) -> str:
+ return self.func("COLUMNS", *expression.expressions)
+
def jsontable_sql(self, expression: exp.JSONTable) -> str:
this = self.sql(expression, "this")
path = self.sql(expression, "path")
@@ -2194,9 +2203,9 @@ class Generator:
error_handling = f" {error_handling}" if error_handling else ""
empty_handling = expression.args.get("empty_handling")
empty_handling = f" {empty_handling}" if empty_handling else ""
- columns = f" COLUMNS ({self.expressions(expression, skip_first=True)})"
+ schema = self.sql(expression, "schema")
return self.func(
- "JSON_TABLE", this, suffix=f"{path}{error_handling}{empty_handling}{columns})"
+ "JSON_TABLE", this, suffix=f"{path}{error_handling}{empty_handling} {schema})"
)
def openjsoncolumndef_sql(self, expression: exp.OpenJSONColumnDef) -> str: