Skip to content

Commit

Permalink
Handling T64, DoubleDelta, Gorilla codec (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadgaur authored Jul 17, 2024
1 parent 11f26f8 commit 6a6d450
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 127 deletions.
8 changes: 5 additions & 3 deletions parser/parser_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,10 +801,12 @@ func (p *Parser) tryParseCompressionCodecs(pos Pos) (*CompressionCodec, error) {
if err != nil {
return nil, err
}
// parse DELTA if CODEC(Delta, ZSTD(1)) or CODEC(Delta(9), ZSTD(1))
// parse DELTA if CODEC(Delta, ZSTD(1))
// or CODEC(Delta(9), ZSTD(1)) or CODEC(T64, ZSTD(1))
var codecType *Ident
var typeLevel *NumberLiteral
if strings.ToUpper(name.Name) == "DELTA" {
switch strings.ToUpper(name.Name) {
case "DELTA", "DOUBLEDELTA", "T64", "GORILLA":
codecType = name
// try parse delta level
typeLevel, err = p.tryParseCompressionLevel(p.Pos())
Expand All @@ -824,7 +826,7 @@ func (p *Parser) tryParseCompressionCodecs(pos Pos) (*CompressionCodec, error) {
var level *NumberLiteral
// TODO: check if the codec name is valid
switch strings.ToUpper(name.Name) {
case "ZSTD", "LZ4HC":
case "ZSTD", "LZ4HC", "LH4":
level, err = p.tryParseCompressionLevel(p.Pos())
if err != nil {
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions parser/testdata/ddl/create_table_with_codec_delta.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ 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)),
`device_id` UInt64 CODEC(DoubleDelta, ZSTD(1)),
`guage` Float64 CODEC(Gorilla, LZ4),
`value` UInt64 CODEC(T64, LZ4),
`timestamp` DateTime64(9) CODEC(ZSTD(1)),
INDEX timestamp_index(timestamp) TYPE minmax GRANULARITY 4
)
Expand Down
6 changes: 6 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 @@ -4,6 +4,9 @@ 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)),
`device_id` UInt64 CODEC(DoubleDelta, ZSTD(1)),
`guage` Float64 CODEC(Gorilla, LZ4),
`value` UInt64 CODEC(T64, LZ4),
`timestamp` DateTime64(9) CODEC(ZSTD(1)),
INDEX timestamp_index(timestamp) TYPE minmax GRANULARITY 4
)
Expand All @@ -20,6 +23,9 @@ 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)),
`device_id` UInt64 CODEC(DoubleDelta, ZSTD(1)),
`guage` Float64 CODEC(Gorilla, LZ4),
`value` UInt64 CODEC(T64, LZ4),
`timestamp` DateTime64(9) CODEC(ZSTD(1)),
INDEX timestamp_index(timestamp) TYPE minmax GRANULARITY 4
)
Expand Down
Loading

0 comments on commit 6a6d450

Please sign in to comment.