Skip to content

Commit

Permalink
Handling Delta with number literal (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadgaur authored Jul 16, 2024
1 parent 5c4ca69 commit f770c15
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 125 deletions.
7 changes: 6 additions & 1 deletion parser/parser_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,10 +801,15 @@ func (p *Parser) tryParseCompressionCodecs(pos Pos) (*CompressionCodec, error) {
if err != nil {
return nil, err
}
// parse DELTA if CODEC(Delta, ZSTD(1))
// parse DELTA if CODEC(Delta, ZSTD(1)) or CODEC(Delta(9), ZSTD(1))
var codecType *Ident
if strings.ToUpper(name.Name) == "DELTA" {
codecType = name
// try parse delta level
if _, err := p.tryParseCompressionLevel(p.Pos()); err != nil {
return nil, err
}
// consume comma
if _, err := p.consumeTokenKind(","); err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions parser/testdata/ddl/create_table_with_codec_delta.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CREATE TABLE IF NOT EXISTS test_local
(
`id` UInt64 CODEC(Delta, ZSTD(1)),
`api_id` UInt64 CODEC(ZSTD(1)),
`app_id` UInt64 CODEC(Delta(9), ZSTD(1)),
`timestamp` DateTime64(9) CODEC(ZSTD(1)),
INDEX timestamp_index(timestamp) TYPE minmax GRANULARITY 4
)
Expand Down
2 changes: 2 additions & 0 deletions parser/testdata/ddl/format/create_table_with_codec_delta.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ CREATE TABLE IF NOT EXISTS test_local
(
`id` UInt64 CODEC(Delta, ZSTD(1)),
`api_id` UInt64 CODEC(ZSTD(1)),
`app_id` UInt64 CODEC(Delta(9), ZSTD(1)),
`timestamp` DateTime64(9) CODEC(ZSTD(1)),
INDEX timestamp_index(timestamp) TYPE minmax GRANULARITY 4
)
Expand All @@ -18,6 +19,7 @@ CREATE TABLE IF NOT EXISTS test_local
(
`id` UInt64 CODEC(Delta, ZSTD(1)),
`api_id` UInt64 CODEC(ZSTD(1)),
`app_id` UInt64 CODEC(Delta, ZSTD(1)),
`timestamp` DateTime64(9) CODEC(ZSTD(1)),
INDEX timestamp_index(timestamp) TYPE minmax GRANULARITY 4
)
Expand Down
Loading

0 comments on commit f770c15

Please sign in to comment.