-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdialect.py
More file actions
34 lines (27 loc) · 816 Bytes
/
dialect.py
File metadata and controls
34 lines (27 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from __future__ import annotations
from sqlglot.dialects.hive import Hive
from sqlglot.tokens import TokenType
from sqlglot_maxcompute.generator import MaxComputeGenerator
from sqlglot_maxcompute.parser import MaxComputeParser
class MaxCompute(Hive):
TIME_MAPPING = {
"yyyy": "%Y",
"yy": "%y",
"mm": "%m",
"dd": "%d",
"hh": "%H",
"mi": "%M",
"ss": "%S",
"ff3": "%f",
}
DATE_FORMAT = "'yyyy-mm-dd'"
TIME_FORMAT = "'yyyy-mm-dd hh:mi:ss'"
class Tokenizer(Hive.Tokenizer):
KEYWORDS = {
**Hive.Tokenizer.KEYWORDS,
"EXPORT": TokenType.EXPORT,
"LIFECYCLE": TokenType.KEY,
"OPTION": TokenType.OPTION,
}
Parser = MaxComputeParser
Generator = MaxComputeGenerator