Skip to content

Commit

Permalink
Feat(presto): add IPADDRESS/IPPREFIX data types (#1965)
Browse files Browse the repository at this point in the history
* Presto: Add IPADDRESS data type

* Linter

* Presto: Add IPPREFIX data type

* Presto: Add IPPREFIX keyword
  • Loading branch information
roykoand authored Jul 27, 2023
1 parent 9787329 commit 5e641c2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sqlglot/dialects/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ class Tokenizer(tokens.Tokenizer):
"START": TokenType.BEGIN,
"MATCH_RECOGNIZE": TokenType.MATCH_RECOGNIZE,
"ROW": TokenType.STRUCT,
"IPADDRESS": TokenType.IPADDRESS,
"IPPREFIX": TokenType.IPPREFIX,
}

class Parser(parser.Parser):
Expand Down
2 changes: 2 additions & 0 deletions sqlglot/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3377,6 +3377,8 @@ class Type(AutoName):
HSTORE = auto()
IMAGE = auto()
INET = auto()
IPADDRESS = auto()
IPPREFIX = auto()
INT = auto()
INT128 = auto()
INT256 = auto()
Expand Down
2 changes: 2 additions & 0 deletions sqlglot/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ class Parser(metaclass=_Parser):
TokenType.VARIANT,
TokenType.OBJECT,
TokenType.INET,
TokenType.IPADDRESS,
TokenType.IPPREFIX,
TokenType.ENUM,
*NESTED_TYPE_TOKENS,
}
Expand Down
2 changes: 2 additions & 0 deletions sqlglot/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ class TokenType(AutoName):
VARIANT = auto()
OBJECT = auto()
INET = auto()
IPADDRESS = auto()
IPPREFIX = auto()
ENUM = auto()

# keywords
Expand Down
2 changes: 2 additions & 0 deletions tests/dialects/test_presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def test_cast(self):
"spark": "CAST(x AS TIMESTAMP)",
},
)
self.validate_identity("CAST(x AS IPADDRESS)")
self.validate_identity("CAST(x AS IPPREFIX)")

def test_regex(self):
self.validate_all(
Expand Down

0 comments on commit 5e641c2

Please sign in to comment.