Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ public String toString() {
// length.
return typeName + "(" + ((ASTlength) children[0]) + ")";
case "ARRAY":
return "ARRAY<" + ((ASTcolumn_type) children[0]) + ">";
String arrayType = "ARRAY<" + ((ASTcolumn_type) children[0]) + ">";
if (jjtGetNumChildren() > 1) {
return arrayType
+ "(vector_length=>"
+ ((SimpleNode) children[1]).jjtGetLastToken().toString()
+ ")";
}
return arrayType;
case "PG": // PG.pgtype
return AstTreeUtils.tokensToString(this).toUpperCase(Locale.ROOT);
case "STRUCT":
Expand Down
1 change: 1 addition & 0 deletions src/main/jjtree-sources/ddl_expression.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void googlesql_operator() :
| "-"
| "*"
| "/"
| "=>"
| "="
| "!="
| "<>"
Expand Down
2 changes: 1 addition & 1 deletion src/main/jjtree-sources/ddl_parser.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void column_type() :
| <UUID>
| <INTERVAL>
| <ARRAY> "<" column_type() ">"
[ "(" <VECTOR_LENGTH> "="">" <INTEGER_LITERAL> #vector_length ")"]
[ "(" <VECTOR_LENGTH> "=>" <INTEGER_LITERAL> #vector_length ")"]
| <TOKENLIST>
| <STRUCT> ( "<" struct_fields() ">" | "<>" )
| dotted_path()
Expand Down
8 changes: 8 additions & 0 deletions src/test/resources/ddlParserValidation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,12 @@ CREATE TABLE test1 ( keycol INT64 NOT NULL PRIMARY KEY, value INT64 )

CREATE TABLE test1 ( keycol INT64, value INT64 )

== Test 24 named params using => in generation expression

CREATE TABLE test_named_params ( key INT64, key_tokens TOKENLIST AS ( TOKENIZE_SUBSTRING ( key, ngram_size_min => 3, ngram_size_max => 3, relative_search_types => [ 'word_prefix' ] ) ) HIDDEN ) PRIMARY KEY (key)

== Test 25 ARRAY with vector_length=>

CREATE TABLE test_vector_length ( key INT64, embedding ARRAY<FLOAT32>(vector_length=>128) ) PRIMARY KEY (key)

==
4 changes: 4 additions & 0 deletions src/test/resources/expectedDdlDiff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -379,5 +379,9 @@ ALTER TABLE mytable SET OPTIONS (locality_group='lg2')

ALTER TABLE mytable SET OPTIONS (droppedKey=NULL,newKey='value2')

== TEST 75 create table with named params using =>

CREATE TABLE test_named_params ( key INT64, key_tokens TOKENLIST AS ( tokenize_substring ( key, ngram_size_min => 3, ngram_size_max => 3, relative_search_types => [ 'word_prefix' ] ) ) HIDDEN ) PRIMARY KEY (key)

==

7 changes: 7 additions & 0 deletions src/test/resources/newDdl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -592,4 +592,11 @@ create table mytable (keycol int64) primary key(keycol), OPTIONS(locality_group

create table mytable (keycol int64) primary key(keycol), OPTIONS(existingKey='value', newKey='value2')

== TEST 75 create table with named params using =>

create table test_named_params (
key int64,
key_tokens tokenlist as (tokenize_substring(key, ngram_size_min=>3, ngram_size_max=>3, relative_search_types=>['word_prefix'])) hidden
) primary key (key);

==
4 changes: 4 additions & 0 deletions src/test/resources/originalDdl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -591,5 +591,9 @@ create table mytable (keycol int64) primary key(keycol), OPTIONS(locality_group

create table mytable (keycol int64) primary key(keycol), OPTIONS(existingKey='value', droppedKey='value1')

== TEST 75 create table with named params using =>

-- Nothing here

==

Loading