Skip to content

Commit

Permalink
fix flake8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
xnuinside committed Sep 18, 2021
1 parent 1ff8e1b commit 795f076
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
exclude = .github,.git,__pycache__,docs/source/conf.py,old,build,dist,simple_ddl_parser/parsetab.py,simple_ddl_parser/test.py
exclude = .github,.git,__pycache__,docs/source/conf.py,old,build,dist,simple_ddl_parser/parsetab.py,./test.py,simple_ddl_parser/test.py
max-complexity = 10
max-line-length = 120
ignore = C901, W503
7 changes: 0 additions & 7 deletions simple_ddl_parser/ddl_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ def t_ID(self, t):
r"([0-9]\.[0-9])\w|([a-zA-Z_,0-9:><\/\=\-\+\~\%$\*'\()!{}\[\]\"\`]+)"
t.type = tok.symbol_tokens.get(t.value, "ID")
skip_id_tokens = ["(", ")", ","]
print(
t.value not in skip_id_tokens
and self.lexer.is_table
and self.lexer.lp_open
and (self.lexer.last_token == "COMMA" or self.lexer.last_token == "LP")
and t.value.upper() not in tok.first_liners
)
if t.type == "LP":
self.lexer.lp_open += 1
self.lexer.columns_def = True
Expand Down
27 changes: 24 additions & 3 deletions tests/test_hql_output_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -1772,8 +1772,19 @@ def test_output_input_format():
'hdfs://xxxx'
"""
parse_results = DDLParser(ddl).run(output_mode="hql")
expected = [{'columns': [{'name': 'test', 'type': 'STRING', 'size': None, 'references': None, 'unique': False,
'nullable': True, 'default': None, 'check': None, 'comment': "'xxxx'"}], 'primary_key': [], 'alter': {}, 'checks': [], 'index': [], 'partitioned_by': [], 'tablespace': None, 'stored_as': {'outputformat': "'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'", 'inputformat': "'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'"}, 'location': "'hdfs://xxxx'", 'comment': None, 'row_format': {'serde': True, 'java_class': "'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'"}, 'fields_terminated_by': None, 'lines_terminated_by': None, 'map_keys_terminated_by': None, 'collection_items_terminated_by': None, 'external': True, 'schema': None, 'table_name': 'test'}]
expected = [{'columns': [
{'name': 'test', 'type': 'STRING', 'size': None, 'references': None, 'unique': False,
'nullable': True, 'default': None, 'check': None, 'comment': "'xxxx'"}
], 'primary_key': [], 'alter': {}, 'checks': [], 'index': [], 'partitioned_by': [],
'tablespace': None,
'stored_as':
{'outputformat': "'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'",
'inputformat': "'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'"},
'location': "'hdfs://xxxx'", 'comment': None,
'row_format':
{'serde': True, 'java_class': "'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'"},
'fields_terminated_by': None, 'lines_terminated_by': None, 'map_keys_terminated_by': None,
'collection_items_terminated_by': None, 'external': True, 'schema': None, 'table_name': 'test'}]
assert expected == parse_results


Expand All @@ -1783,5 +1794,15 @@ def test_skewed_by():
SKEWED BY (key) ON (1,5,6) STORED AS DIRECTORIES;
"""
parse_results = DDLParser(ddl).run(output_mode="hql")
expected =[{'columns': [{'name': 'key', 'type': 'STRING', 'size': None, 'references': None, 'unique': False, 'nullable': True, 'default': None, 'check': None}, {'name': 'value', 'type': 'STRING', 'size': None, 'references': None, 'unique': False, 'nullable': True, 'default': None, 'check': None}], 'primary_key': [], 'alter': {}, 'checks': [], 'index': [], 'partitioned_by': [], 'tablespace': None, 'stored_as': 'DIRECTORIES', 'location': None, 'comment': None, 'row_format': None, 'fields_terminated_by': None, 'lines_terminated_by': None, 'map_keys_terminated_by': None, 'collection_items_terminated_by': None, 'external': False, 'schema': None, 'table_name': 'list_bucket_single', 'skewed_by': {'key': 'key', 'on': ['1', '5', '6']}}]
expected = [
{'columns': [
{'name': 'key', 'type': 'STRING', 'size': None, 'references': None,
'unique': False, 'nullable': True, 'default': None, 'check': None},
{'name': 'value', 'type': 'STRING', 'size': None, 'references': None,
'unique': False, 'nullable': True, 'default': None, 'check': None}],
'primary_key': [], 'alter': {}, 'checks': [], 'index': [], 'partitioned_by': [],
'tablespace': None, 'stored_as': 'DIRECTORIES', 'location': None, 'comment': None,
'row_format': None, 'fields_terminated_by': None, 'lines_terminated_by': None,
'map_keys_terminated_by': None, 'collection_items_terminated_by': None, 'external': False,
'schema': None, 'table_name': 'list_bucket_single', 'skewed_by': {'key': 'key', 'on': ['1', '5', '6']}}]
assert expected == parse_results

0 comments on commit 795f076

Please sign in to comment.