Skip to content

Commit

Permalink
Merge branch 'main' into fix_cli_missing_init
Browse files Browse the repository at this point in the history
  • Loading branch information
tunetheweb committed Nov 5, 2021
2 parents cd7650b + 8719730 commit 560dbc2
Show file tree
Hide file tree
Showing 19 changed files with 336 additions and 40 deletions.
26 changes: 13 additions & 13 deletions src/sqlfluff/dialects/dialect_exasol.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,9 @@ class WithInvalidForeignKeySegment(BaseSegment):
Ref("BracketedColumnReferenceListGrammar"),
Dedent, # dedent for the indent in the select clause
"FROM",
Ref("ObjectReferenceSegment"),
Ref("TableReferenceSegment"),
"REFERENCING",
Ref("ObjectReferenceSegment"),
Ref("TableReferenceSegment"),
Ref("BracketedColumnReferenceListGrammar", optional=True),
)

Expand All @@ -403,7 +403,7 @@ class IntoTableSegment(BaseSegment):

type = "into_table_clause"
match_grammar = StartsWith(Sequence("INTO", "TABLE"), terminator="FROM")
parse_grammar = Sequence("INTO", "TABLE", Ref("ObjectReferenceSegment"))
parse_grammar = Sequence("INTO", "TABLE", Ref("TableReferenceSegment"))


@exasol_dialect.segment(replace=True)
Expand Down Expand Up @@ -3078,7 +3078,7 @@ class OpenSchemaSegment(BaseSegment):
"""`OPEN SCHEMA` statement."""

type = "open_schema_statement"
match_grammar = Sequence("OPEN", "SCHEMA", Ref("ObjectReferenceSegment"))
match_grammar = Sequence("OPEN", "SCHEMA", Ref("SchemaReferenceSegment"))


@exasol_dialect.segment()
Expand Down Expand Up @@ -3107,12 +3107,12 @@ class RecompressReorganizeSegment(BaseSegment):
OneOf(
Sequence(
"TABLE",
Ref("ObjectReferenceSegment"),
Ref("TableReferenceSegment"),
Ref("BracketedColumnReferenceListGrammar"),
),
Sequence("TABLES", Delimited(Ref("ObjectReferenceSegment"))),
Sequence("SCHEMA", Ref("ObjectReferenceSegment")),
Sequence("SCHEMAS", Delimited(Ref("ObjectReferenceSegment"))),
Sequence("TABLES", Delimited(Ref("TableReferenceSegment"))),
Sequence("SCHEMA", Ref("SchemaReferenceSegment")),
Sequence("SCHEMAS", Delimited(Ref("SchemaReferenceSegment"))),
"DATABASE",
),
Ref.keyword("ENFORCE", optional=True),
Expand All @@ -3129,12 +3129,12 @@ class PreloadSegment(BaseSegment):
OneOf(
Sequence(
"TABLE",
Ref("ObjectReferenceSegment"),
Ref("TableReferenceSegment"),
Ref("BracketedColumnReferenceListGrammar"),
),
Sequence("TABLES", Delimited(Ref("ObjectReferenceSegment"))),
Sequence("SCHEMA", Ref("ObjectReferenceSegment")),
Sequence("SCHEMAS", Delimited(Ref("ObjectReferenceSegment"))),
Sequence("TABLES", Delimited(Ref("TableReferenceSegment"))),
Sequence("SCHEMA", Ref("SchemaReferenceSegment")),
Sequence("SCHEMAS", Delimited(Ref("SchemaReferenceSegment"))),
"DATABASE",
),
)
Expand Down Expand Up @@ -3214,7 +3214,7 @@ class ExecuteScriptSegment(BaseSegment):
match_grammar = Sequence(
"EXECUTE",
"SCRIPT",
Ref("ObjectReferenceSegment"),
Ref("ScriptReferenceSegment"),
Bracketed(
Delimited(Ref.keyword("ARRAY", optional=True), Ref("ExpressionSegment")),
optional=True,
Expand Down
47 changes: 47 additions & 0 deletions src/sqlfluff/dialects/dialect_hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,3 +507,50 @@ class StatementSegment(ansi_dialect.get_segment("StatementSegment")): # type: i
Ref("DropModelStatementSegment"),
],
)


@hive_dialect.segment(replace=True)
class InsertStatementSegment(BaseSegment):
"""An `INSERT` statement.
Full Apache Hive `INSERT` reference here:
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML
"""

type = "insert_statement"
match_grammar = StartsWith("INSERT")
parse_grammar = Sequence(
"INSERT",
OneOf(
Sequence(
"OVERWRITE",
OneOf(
Sequence(
"TABLE",
Ref("TableReferenceSegment"),
Ref("PartitionSpecGrammar", optional=True),
Ref("IfNotExistsGrammar", optional=True),
Ref("SelectableGrammar"),
),
Sequence(
Sequence("LOCAL", optional=True),
"DIRECTORY",
Ref("SingleOrDoubleQuotedLiteralGrammar"),
Ref("RowFormatClauseSegment", optional=True),
Ref("StoredAsGrammar", optional=True),
Ref("SelectableGrammar"),
),
),
),
Sequence(
"INTO",
"TABLE",
Ref("TableReferenceSegment"),
Ref("PartitionSpecGrammar", optional=True),
OneOf(
Ref("SelectableGrammar"),
Ref("ValuesClauseSegment"),
),
),
),
)
10 changes: 5 additions & 5 deletions test/fixtures/dialects/exasol/ExecuteScript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: 6681b20a2a0f43830205d4e154910b53cfb41982f4e1a437cdce9ef6ad8c9f09
_hash: 996e085117024ed5ade66d3fb0c8e56e06a45e98e894f5bf8f38a64eeaa971bf
file:
- statement:
execute_script_statement:
- keyword: EXECUTE
- keyword: SCRIPT
- object_reference:
- script_reference:
identifier: script_1
- statement_terminator: ;
- statement:
execute_script_statement:
- keyword: EXECUTE
- keyword: SCRIPT
- object_reference:
- script_reference:
identifier: script_1
- keyword: WITH
- keyword: OUTPUT
Expand All @@ -25,7 +25,7 @@ file:
execute_script_statement:
- keyword: EXECUTE
- keyword: SCRIPT
- object_reference:
- script_reference:
identifier: script_2
- bracketed:
- start_bracket: (
Expand All @@ -45,7 +45,7 @@ file:
execute_script_statement:
- keyword: EXECUTE
- keyword: SCRIPT
- object_reference:
- script_reference:
identifier: script_3
- bracketed:
start_bracket: (
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/dialects/exasol/OpenCloseSchema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: 0a2e62784075b09001ce7e5f5664ff92edf451c5681f2238d7a40ce254d997ea
_hash: 451857e48ad7d4bea308e653fcb46058a99cec1bc416eeab1da865ef5ba1d6a6
file:
- statement:
open_schema_statement:
- keyword: OPEN
- keyword: SCHEMA
- object_reference:
- schema_reference:
identifier: test
- statement_terminator: ;
- statement:
open_schema_statement:
- keyword: OPEN
- keyword: SCHEMA
- object_reference:
- schema_reference:
identifier: '"test"'
- statement_terminator: ;
- statement:
Expand Down
14 changes: 7 additions & 7 deletions test/fixtures/dialects/exasol/PreloadStatement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: fc832df27cdfa5ec9952229ae0d8730944f1a63d0b6f92f57cd1649af6cd98f3
_hash: 8ccdfc4bd57a103aa969a16ee2fe5629a5aafc35c388b9dd597eb941e28a7066
file:
- statement:
preload_statement:
- keyword: PRELOAD
- keyword: TABLE
- object_reference:
- table_reference:
identifier: t
- bracketed:
start_bracket: (
Expand All @@ -26,27 +26,27 @@ file:
preload_statement:
- keyword: PRELOAD
- keyword: TABLES
- object_reference:
- table_reference:
identifier: t1
- comma: ','
- object_reference:
- table_reference:
identifier: t2
- statement_terminator: ;
- statement:
preload_statement:
- keyword: PRELOAD
- keyword: SCHEMAS
- object_reference:
- schema_reference:
identifier: s1
- comma: ','
- object_reference:
- schema_reference:
identifier: s2
- statement_terminator: ;
- statement:
preload_statement:
- keyword: PRELOAD
- keyword: SCHEMA
- object_reference:
- schema_reference:
identifier: s1
- statement_terminator: ;
- statement:
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/dialects/exasol/RecompressStatement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: 12717d423891499caf01b58d7ee219869c78cf89ef38ce5ca72305e1121c2a5f
_hash: 53a6f747c711b3806acd9c82f64dfd18084a610b473ce52227459a2817d741ce
file:
- statement:
recompress_reorganize_statement:
- keyword: RECOMPRESS
- keyword: TABLE
- object_reference:
- table_reference:
identifier: t1
- bracketed:
start_bracket: (
Expand All @@ -21,10 +21,10 @@ file:
recompress_reorganize_statement:
- keyword: RECOMPRESS
- keyword: TABLES
- object_reference:
- table_reference:
identifier: t2
- comma: ','
- object_reference:
- table_reference:
identifier: t3
- keyword: ENFORCE
- statement_terminator: ;
16 changes: 8 additions & 8 deletions test/fixtures/dialects/exasol/SelectStatement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: c18d191e0be145ed6b398d233eaca31d5890e8a3bce7a725c72cdca21126215b
_hash: c779ff30a065b616a67966cb4168c174892973c083415a6b0168ace96a4dbdc0
file:
- statement:
select_statement:
Expand Down Expand Up @@ -807,10 +807,10 @@ file:
identifier: nr
end_bracket: )
- keyword: from
- object_reference:
- table_reference:
identifier: T1
- keyword: REFERENCING
- object_reference:
- table_reference:
identifier: T2
- bracketed:
start_bracket: (
Expand Down Expand Up @@ -839,10 +839,10 @@ file:
identifier: name
- end_bracket: )
- keyword: from
- object_reference:
- table_reference:
identifier: T1
- keyword: REFERENCING
- object_reference:
- table_reference:
identifier: T2
- statement_terminator: ;
- statement:
Expand All @@ -864,10 +864,10 @@ file:
identifier: name
- end_bracket: )
- keyword: from
- object_reference:
- table_reference:
identifier: T1
- keyword: REFERENCING
- object_reference:
- table_reference:
identifier: T2
- bracketed:
- start_bracket: (
Expand All @@ -892,7 +892,7 @@ file:
into_table_clause:
- keyword: INTO
- keyword: TABLE
- object_reference:
- table_reference:
identifier: t2
from_clause:
keyword: FROM
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/dialects/hive/insert_into_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO TABLE foo
SELECT a, b FROM bar;
32 changes: 32 additions & 0 deletions test/fixtures/dialects/hive/insert_into_table.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# YML test files are auto-generated from SQL files and should not be edited by
# hand. To help enforce this, the "hash" field in the file must match a hash
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: d4bcf9077cf6a10011ca75dfeb29a04b441b9b34575c5c548ea7243571b7af32
file:
statement:
insert_statement:
- keyword: INSERT
- keyword: INTO
- keyword: TABLE
- table_reference:
identifier: foo
- select_statement:
select_clause:
- keyword: SELECT
- select_clause_element:
column_reference:
identifier: a
- comma: ','
- select_clause_element:
column_reference:
identifier: b
from_clause:
keyword: FROM
from_expression:
from_expression_element:
table_expression:
table_reference:
identifier: bar
statement_terminator: ;
3 changes: 3 additions & 0 deletions test/fixtures/dialects/hive/insert_into_table_partition.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSERT INTO TABLE foo
PARTITION (a='test_foo', b='test_bar')
SELECT a, b, c, d FROM bar;

0 comments on commit 560dbc2

Please sign in to comment.