summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/athena.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 08:11:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 08:12:02 +0000
commit8d36f5966675e23bee7026ba37ae0647fbf47300 (patch)
treedf4227bbb3b07cb70df87237bcff03c8efd7822d /sqlglot/dialects/athena.py
parentReleasing debian version 22.2.0-1. (diff)
downloadsqlglot-8d36f5966675e23bee7026ba37ae0647fbf47300.tar.xz
sqlglot-8d36f5966675e23bee7026ba37ae0647fbf47300.zip
Merging upstream version 23.7.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/athena.py')
-rw-r--r--sqlglot/dialects/athena.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/sqlglot/dialects/athena.py b/sqlglot/dialects/athena.py
new file mode 100644
index 0000000..f2deec8
--- /dev/null
+++ b/sqlglot/dialects/athena.py
@@ -0,0 +1,37 @@
+from __future__ import annotations
+
+from sqlglot import exp
+from sqlglot.dialects.trino import Trino
+from sqlglot.tokens import TokenType
+
+
+class Athena(Trino):
+ class Parser(Trino.Parser):
+ STATEMENT_PARSERS = {
+ **Trino.Parser.STATEMENT_PARSERS,
+ TokenType.USING: lambda self: self._parse_as_command(self._prev),
+ }
+
+ class Generator(Trino.Generator):
+ PROPERTIES_LOCATION = {
+ **Trino.Generator.PROPERTIES_LOCATION,
+ exp.LocationProperty: exp.Properties.Location.POST_SCHEMA,
+ }
+
+ TYPE_MAPPING = {
+ **Trino.Generator.TYPE_MAPPING,
+ exp.DataType.Type.TEXT: "STRING",
+ }
+
+ TRANSFORMS = {
+ **Trino.Generator.TRANSFORMS,
+ exp.FileFormatProperty: lambda self, e: f"'FORMAT'={self.sql(e, 'this')}",
+ }
+
+ def property_sql(self, expression: exp.Property) -> str:
+ return (
+ f"{self.property_name(expression, string_key=True)}={self.sql(expression, 'value')}"
+ )
+
+ def with_properties(self, properties: exp.Properties) -> str:
+ return self.properties(properties, prefix=self.seg("TBLPROPERTIES"))