@@ -644,7 +644,9 @@ def test_double_single_quotes():
644
644
645
645
def test_autoincrement_order ():
646
646
# test for https://github.com/xnuinside/simple-ddl-parser/issues/208
647
- ddl = """CREATE TABLE table (surrogatekey_SK NUMBER(38,0) NOT NULL autoincrement start 1 increment 1 ORDER COMMENT 'Record Identification Number Ordered')"""
647
+ ddl = """CREATE TABLE table (
648
+ surrogatekey_SK NUMBER(38,0) NOT NULL autoincrement start 1 increment 1
649
+ ORDER COMMENT 'Record Identification Number Ordered')"""
648
650
result = DDLParser (ddl ).run (group_by_type = True )
649
651
expected = {
650
652
"ddl_properties" : [],
@@ -667,9 +669,9 @@ def test_autoincrement_order():
667
669
"type" : "NUMBER" ,
668
670
"unique" : False ,
669
671
"autoincrement" : True ,
670
- "start" : '1' ,
671
- "increment" : '1' ,
672
- "increment_order" : True
672
+ "start" : "1" ,
673
+ "increment" : "1" ,
674
+ "increment_order" : True ,
673
675
}
674
676
],
675
677
"index" : [],
@@ -684,10 +686,13 @@ def test_autoincrement_order():
684
686
}
685
687
print (result )
686
688
assert result == expected
687
-
689
+
690
+
688
691
def test_autoincrement_noorder ():
689
692
# test for https://github.com/xnuinside/simple-ddl-parser/issues/208
690
- ddl = """CREATE TABLE table (surrogatekey_SK NUMBER(38,0) NOT NULL autoincrement start 1 increment 1 NOORDER COMMENT 'Record Identification Number NoOrdered')"""
693
+ ddl = """CREATE TABLE table (
694
+ surrogatekey_SK NUMBER(38,0) NOT NULL autoincrement start 1 increment 1
695
+ NOORDER COMMENT 'Record Identification Number NoOrdered')"""
691
696
result = DDLParser (ddl ).run (group_by_type = True )
692
697
expected = {
693
698
"ddl_properties" : [],
@@ -710,9 +715,9 @@ def test_autoincrement_noorder():
710
715
"type" : "NUMBER" ,
711
716
"unique" : False ,
712
717
"autoincrement" : True ,
713
- "start" : '1' ,
714
- "increment" : '1' ,
715
- "increment_order" : False
718
+ "start" : "1" ,
719
+ "increment" : "1" ,
720
+ "increment_order" : False ,
716
721
}
717
722
],
718
723
"index" : [],
@@ -728,26 +733,7 @@ def test_autoincrement_noorder():
728
733
print (result )
729
734
assert result == expected
730
735
731
- def test_order_sequence ():
732
- parse_results = DDLParser (
733
- """
734
- CREATE SEQUENCE dev.incremental_ids_order
735
- START 1
736
- INCREMENT 1
737
- ORDER;
738
- """
739
- ).run ()
740
- expected = [
741
- {
742
- "schema" : "dev" ,
743
- "sequence_name" : "incremental_ids" ,
744
- "increment" : 1 ,
745
- "start" : 1 ,
746
- "order" : True ,
747
- }
748
- ]
749
- assert expected == parse_results
750
-
736
+
751
737
def test_order_sequence ():
752
738
parse_results = DDLParser (
753
739
"""
@@ -769,6 +755,7 @@ def test_order_sequence():
769
755
]
770
756
assert expected == parse_results
771
757
758
+
772
759
def test_virtual_column_ext_table ():
773
760
ddl = """
774
761
create or replace external table if not exists TABLE_DATA_SRC.EXT_PAYLOAD_MANIFEST_WEB (
@@ -802,8 +789,10 @@ def test_virtual_column_ext_table():
802
789
"nullable" : True ,
803
790
"default" : None ,
804
791
"check" : None ,
805
- "generated" : {"as" : "SPLIT_PART(SPLIT_PART(METADATA$FILENAME,'/',1),'=',2)" }
806
- } ,
792
+ "generated" : {
793
+ "as" : "SPLIT_PART(SPLIT_PART(METADATA$FILENAME,'/',1),'=',2)"
794
+ },
795
+ },
807
796
{
808
797
"name" : "year" ,
809
798
"type" : "VARCHAR" ,
@@ -813,7 +802,9 @@ def test_virtual_column_ext_table():
813
802
"nullable" : True ,
814
803
"default" : None ,
815
804
"check" : None ,
816
- "generated" : {"as" : "SPLIT_PART(SPLIT_PART(METADATA$FILENAME,'/',2),'=',2)" }
805
+ "generated" : {
806
+ "as" : "SPLIT_PART(SPLIT_PART(METADATA$FILENAME,'/',2),'=',2)"
807
+ },
817
808
},
818
809
{
819
810
"name" : "month" ,
@@ -824,7 +815,9 @@ def test_virtual_column_ext_table():
824
815
"nullable" : True ,
825
816
"default" : None ,
826
817
"check" : None ,
827
- "generated" : {"as" : "SPLIT_PART(SPLIT_PART(METADATA$FILENAME,'/',3),'=',2)" }
818
+ "generated" : {
819
+ "as" : "SPLIT_PART(SPLIT_PART(METADATA$FILENAME,'/',3),'=',2)"
820
+ },
828
821
},
829
822
{
830
823
"name" : "day" ,
@@ -835,7 +828,9 @@ def test_virtual_column_ext_table():
835
828
"nullable" : True ,
836
829
"default" : None ,
837
830
"check" : None ,
838
- "generated" : {"as" : "SPLIT_PART(SPLIT_PART(METADATA$FILENAME,'/',4),'=',2)" }
831
+ "generated" : {
832
+ "as" : "SPLIT_PART(SPLIT_PART(METADATA$FILENAME,'/',4),'=',2)"
833
+ },
839
834
},
840
835
{
841
836
"name" : "path" ,
@@ -846,26 +841,30 @@ def test_virtual_column_ext_table():
846
841
"nullable" : True ,
847
842
"default" : None ,
848
843
"check" : None ,
849
- "generated" : {"as" : "METADATA$FILENAME" }
850
- }
844
+ "generated" : {"as" : "METADATA$FILENAME" },
845
+ },
851
846
],
852
847
"index" : [],
853
- "partition_by" : { "columns" :["type" , "year" , "month" , "day" , "path" ], "type" : None },
854
- "partitioned_by" : [],
848
+ "partition_by" : {
849
+ "columns" : ["type" , "year" , "month" , "day" , "path" ],
850
+ "type" : None ,
851
+ },
852
+ "partitioned_by" : [],
855
853
"primary_key" : [],
856
854
"primary_key_enforced" : None ,
857
- "auto_refresh" : False ,
855
+ "auto_refresh" : False ,
858
856
"schema" : "TABLE_DATA_SRC" ,
859
857
"table_name" : "EXT_PAYLOAD_MANIFEST_WEB" ,
860
858
"tablespace" : None ,
861
- "replace" : True ,
859
+ "replace" : True ,
862
860
"if_not_exists" : True ,
863
- "location" : "@ADL_Azure_Storage_Account_Container_Name/" ,
861
+ "location" : "@ADL_Azure_Storage_Account_Container_Name/" ,
864
862
}
865
863
]
866
864
867
865
assert result_ext_table == expected_ext_table
868
866
867
+
869
868
def test_virtual_column_table ():
870
869
ddl = """
871
870
create or replace table if not exists TABLE_DATA_SRC.EXT_PAYLOAD_MANIFEST_WEB (
@@ -907,23 +906,28 @@ def test_virtual_column_table():
907
906
"nullable" : True ,
908
907
"default" : None ,
909
908
"check" : None ,
910
- "generated" : {"as" : "id * 10" }
911
- }
909
+ "generated" : {"as" : "id * 10" },
910
+ },
912
911
],
913
912
"index" : [],
914
- "partitioned_by" : [],
913
+ "partitioned_by" : [],
915
914
"primary_key" : [],
916
915
"primary_key_enforced" : None ,
917
- "auto_refresh" : False ,
916
+ "auto_refresh" : False ,
918
917
"schema" : "TABLE_DATA_SRC" ,
919
918
"table_name" : "EXT_PAYLOAD_MANIFEST_WEB" ,
920
919
"tablespace" : None ,
921
- "replace" : True ,
920
+ "replace" : True ,
922
921
"if_not_exists" : True ,
923
- "location" : "@ADL_Azure_Storage_Account_Container_Name/" ,
924
- "file_format" : ['TYPE=JSON' , "NULL_IF=('field')" ,'DATE_FORMAT=AUTO' ,'TRIM_SPACE=TRUE' ],
925
- 'stage_file_format' : ['TYPE=JSON' ,'NULL_IF=()' ]
926
- }
922
+ "location" : "@ADL_Azure_Storage_Account_Container_Name/" ,
923
+ "file_format" : [
924
+ "TYPE=JSON" ,
925
+ "NULL_IF=('field')" ,
926
+ "DATE_FORMAT=AUTO" ,
927
+ "TRIM_SPACE=TRUE" ,
928
+ ],
929
+ "stage_file_format" : ["TYPE=JSON" , "NULL_IF=()" ],
930
+ }
927
931
]
928
932
929
- assert result_ext_table == expected_ext_table
933
+ assert result_ext_table == expected_ext_table
0 commit comments