Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion parser/parser_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,11 @@ func (p *Parser) parseSettingsExpr(pos Pos) (*SettingExpr, error) {
Literal: curToken.String,
}
default:
return nil, fmt.Errorf("unexpected token: %q, expected <number>, <bool> or <string>", p.currentTokenString())
value, err := p.parseExpr(p.Pos())
if err != nil {
return nil, fmt.Errorf("invalid setting value: %w", err)
}
expr = value
}

return &SettingExpr{
Expand Down
17 changes: 17 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ import (

var runCompatible = flag.Bool("compatible", false, "run compatible test")

func TestParser_TableSettingsFunctionExpression(t *testing.T) {
t.Parallel()

tests := map[string]string{
"function": `CREATE TABLE t (timestamp DateTime64(9)) ENGINE = MergeTree ORDER BY timestamp SETTINGS table_disk = true, disk = disk(type = 's3_plain_rewritable', endpoint = 'from_env GCS_STORAGE_PATH_DATA', readonly = true)`,
"nested function": `CREATE TABLE t (timestamp DateTime64(9)) ENGINE = MergeTree ORDER BY timestamp SETTINGS table_disk = true, disk = disk(name = 'cache', type = 'cache', path = 'from_env CACHE_PATH', max_size = 'from_env CACHE_SIZE', enable_filesystem_query_cache_limit = true, disk = disk(type = 's3_plain_rewritable', endpoint = '[HIDDEN]', readonly = '[HIDDEN]'))`,
}

for name, query := range tests {
t.Run(name, func(t *testing.T) {
exprs, err := NewParser(query).ParseStmts()
require.NoError(t, err)
require.Len(t, exprs, 1)
})
}
}

func TestParser_Compatible(t *testing.T) {
if !*runCompatible {
t.Skip("Compatible test runs only if -compatible is set")
Expand Down
Loading