diff --git a/README.md b/README.md index 775d3af2f..215696258 100644 --- a/README.md +++ b/README.md @@ -272,7 +272,7 @@ for that setup the `chroma` executable can be just symlinked to `~/.lessfilter`. If you edit some lexers and want to try it, open a shell in `cmd/chromad` and run: ```shell -go run . +go run . --csrf-key=securekey ``` A Link will be printed. Open it in your Browser. Now you can test on the Playground with your local changes. diff --git a/lexers/embedded/materialize_sql_dialect.xml b/lexers/embedded/materialize_sql_dialect.xml index 7b22a46c6..845934404 100644 --- a/lexers/embedded/materialize_sql_dialect.xml +++ b/lexers/embedded/materialize_sql_dialect.xml @@ -1,154 +1,154 @@ Materialize SQL dialect - materialize - mzsql text/x-materializesql true true + materialize + mzsql - + - + - - + + - + - + 6 12 - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - + - + - + - + - + - + - - + + - + - + - - + + - + - + 12 4 - - - - - - - - - - - - - + + + + + + + + + + + + + - + - + - - + + - + - - + + - - + + - + - + - - + + - - + + - - - + + + - - + + - - + + - - - + + + diff --git a/lexers/testdata/materialize.actual b/lexers/testdata/materialize.actual new file mode 100644 index 000000000..fc12f27d0 --- /dev/null +++ b/lexers/testdata/materialize.actual @@ -0,0 +1,49 @@ +-- basic statements + +CREATE VIEW my_typed_source AS + SELECT + (data->>'field1')::boolean AS field_1, + (data->>'field2')::int AS field_2, + (data->>'field3')::float AS field_3 + FROM my_jsonb_source; + +WITH + regional_sales (region, total_sales) AS ( + SELECT region, sum(amount) + FROM orders + GROUP BY region + ), + top_regions AS ( + SELECT region + FROM regional_sales + ORDER BY total_sales DESC + LIMIT 5 + ) +SELECT region, + product, + SUM(quantity) AS product_units, + SUM(amount) AS product_sales +FROM orders +WHERE region IN (SELECT region FROM top_regions) +GROUP BY region, product; + +-- sources + +CREATE SOURCE webhook_with_basic_auth +FROM WEBHOOK + BODY FORMAT JSON + CHECK ( + WITH ( + HEADERS, + BODY AS request_body, + SECRET basic_hook_auth AS validation_secret + ) + -- The constant_time_eq validation function **does not support** fully + -- qualified secret names. We recommend always aliasing the secret name + -- for ease of use. + constant_time_eq(headers->'authorization', validation_secret) + ); + +CREATE SOURCE mz_source + FROM MYSQL CONNECTION mysql_connection + FOR TABLES (schema1.table_1 AS s1_table_1, schema2.table_1 AS s2_table_1); diff --git a/lexers/testdata/materialize.expected b/lexers/testdata/materialize.expected new file mode 100644 index 000000000..875fde7d9 --- /dev/null +++ b/lexers/testdata/materialize.expected @@ -0,0 +1,280 @@ +[ + {"type":"CommentSingle","value":"-- basic statements\n"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"CREATE"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"VIEW"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"my_typed_source"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"AS"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"SELECT"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"data"}, + {"type":"Operator","value":"-\u003e\u003e"}, + {"type":"LiteralStringSingle","value":"'field1'"}, + {"type":"Punctuation","value":")"}, + {"type":"Operator","value":"::"}, + {"type":"NameBuiltin","value":"boolean"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"AS"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"field_1"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"data"}, + {"type":"Operator","value":"-\u003e\u003e"}, + {"type":"LiteralStringSingle","value":"'field2'"}, + {"type":"Punctuation","value":")"}, + {"type":"Operator","value":"::"}, + {"type":"NameBuiltin","value":"int"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"AS"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"field_2"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"data"}, + {"type":"Operator","value":"-\u003e\u003e"}, + {"type":"LiteralStringSingle","value":"'field3'"}, + {"type":"Punctuation","value":")"}, + {"type":"Operator","value":"::"}, + {"type":"Keyword","value":"float"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"AS"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"field_3"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"FROM"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"my_jsonb_source"}, + {"type":"Punctuation","value":";"}, + {"type":"Text","value":"\n\n"}, + {"type":"Keyword","value":"WITH"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"regional_sales"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Keyword","value":"region"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Name","value":"total_sales"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"AS"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"SELECT"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"region"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Name","value":"sum"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"amount"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"FROM"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"orders"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"GROUP"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"BY"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"region"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"),"}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"top_regions"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"AS"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"SELECT"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"region"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"FROM"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"regional_sales"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"ORDER"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"BY"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"total_sales"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"DESC"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"LIMIT"}, + {"type":"Text","value":" "}, + {"type":"LiteralNumberFloat","value":"5"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"SELECT"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"region"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"product"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"SUM"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"quantity"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"AS"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"product_units"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":"\n "}, + {"type":"Name","value":"SUM"}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"amount"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"AS"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"product_sales"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"FROM"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"orders"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"WHERE"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"region"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"IN"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Keyword","value":"SELECT"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"region"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"FROM"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"top_regions"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"GROUP"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"BY"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"region"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Name","value":"product"}, + {"type":"Punctuation","value":";"}, + {"type":"Text","value":"\n\n"}, + {"type":"CommentSingle","value":"-- sources\n"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"CREATE"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"SOURCE"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"webhook_with_basic_auth"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"FROM"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"WEBHOOK"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"BODY"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"FORMAT"}, + {"type":"Text","value":" "}, + {"type":"NameBuiltin","value":"JSON"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"CHECK"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"WITH"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"HEADERS"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"BODY"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"AS"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"request_body"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"SECRET"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"basic_hook_auth"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"AS"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"validation_secret"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"CommentSingle","value":"-- The constant_time_eq validation function **does not support** fully\n"}, + {"type":"Text","value":" "}, + {"type":"CommentSingle","value":"-- qualified secret names. We recommend always aliasing the secret name\n"}, + {"type":"Text","value":" "}, + {"type":"CommentSingle","value":"-- for ease of use.\n"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"constant_time_eq"}, + {"type":"Punctuation","value":"("}, + {"type":"Keyword","value":"headers"}, + {"type":"Operator","value":"-\u003e"}, + {"type":"LiteralStringSingle","value":"'authorization'"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Name","value":"validation_secret"}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":");"}, + {"type":"Text","value":"\n\n"}, + {"type":"Keyword","value":"CREATE"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"SOURCE"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"mz_source"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"FROM"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"MYSQL"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"CONNECTION"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"mysql_connection"}, + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"FOR"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"TABLES"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"("}, + {"type":"Name","value":"schema1"}, + {"type":"LiteralNumberFloat","value":"."}, + {"type":"Name","value":"table_1"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"AS"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"s1_table_1"}, + {"type":"Punctuation","value":","}, + {"type":"Text","value":" "}, + {"type":"Name","value":"schema2"}, + {"type":"LiteralNumberFloat","value":"."}, + {"type":"Name","value":"table_1"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"AS"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"s2_table_1"}, + {"type":"Punctuation","value":");"}, + {"type":"Text","value":"\n"} +]