|
12 | 12 | from databricks.sql.backend.sea.conversion import SqlType, SqlTypeConverter |
13 | 13 |
|
14 | 14 |
|
15 | | -class TestSqlType: |
16 | | - """Test suite for the SqlType class.""" |
17 | | - |
18 | | - def test_is_numeric(self): |
19 | | - """Test the is_numeric method.""" |
20 | | - assert SqlType.is_numeric(SqlType.BYTE) |
21 | | - assert SqlType.is_numeric(SqlType.SHORT) |
22 | | - assert SqlType.is_numeric(SqlType.INT) |
23 | | - assert SqlType.is_numeric(SqlType.LONG) |
24 | | - assert SqlType.is_numeric(SqlType.FLOAT) |
25 | | - assert SqlType.is_numeric(SqlType.DOUBLE) |
26 | | - assert SqlType.is_numeric(SqlType.DECIMAL) |
27 | | - |
28 | | - # Test with uppercase |
29 | | - assert SqlType.is_numeric("INT") |
30 | | - assert SqlType.is_numeric("DECIMAL") |
31 | | - |
32 | | - # Test non-numeric types |
33 | | - assert not SqlType.is_numeric(SqlType.STRING) |
34 | | - assert not SqlType.is_numeric(SqlType.BOOLEAN) |
35 | | - assert not SqlType.is_numeric(SqlType.DATE) |
36 | | - |
37 | | - def test_is_boolean(self): |
38 | | - """Test the is_boolean method.""" |
39 | | - assert SqlType.is_boolean(SqlType.BOOLEAN) |
40 | | - assert SqlType.is_boolean("BOOLEAN") |
41 | | - |
42 | | - # Test non-boolean types |
43 | | - assert not SqlType.is_boolean(SqlType.STRING) |
44 | | - assert not SqlType.is_boolean(SqlType.INT) |
45 | | - |
46 | | - def test_is_datetime(self): |
47 | | - """Test the is_datetime method.""" |
48 | | - assert SqlType.is_datetime(SqlType.DATE) |
49 | | - assert SqlType.is_datetime(SqlType.TIMESTAMP) |
50 | | - assert SqlType.is_datetime(SqlType.INTERVAL) |
51 | | - assert SqlType.is_datetime("DATE") |
52 | | - assert SqlType.is_datetime("TIMESTAMP") |
53 | | - |
54 | | - # Test non-datetime types |
55 | | - assert not SqlType.is_datetime(SqlType.STRING) |
56 | | - assert not SqlType.is_datetime(SqlType.INT) |
57 | | - |
58 | | - def test_is_string(self): |
59 | | - """Test the is_string method.""" |
60 | | - assert SqlType.is_string(SqlType.STRING) |
61 | | - assert SqlType.is_string(SqlType.CHAR) |
62 | | - assert SqlType.is_string("STRING") |
63 | | - assert SqlType.is_string("CHAR") |
64 | | - |
65 | | - # Test non-string types |
66 | | - assert not SqlType.is_string(SqlType.INT) |
67 | | - assert not SqlType.is_string(SqlType.BOOLEAN) |
68 | | - |
69 | | - def test_is_binary(self): |
70 | | - """Test the is_binary method.""" |
71 | | - assert SqlType.is_binary(SqlType.BINARY) |
72 | | - assert SqlType.is_binary("BINARY") |
73 | | - |
74 | | - # Test non-binary types |
75 | | - assert not SqlType.is_binary(SqlType.STRING) |
76 | | - assert not SqlType.is_binary(SqlType.INT) |
77 | | - |
78 | | - def test_is_complex(self): |
79 | | - """Test the is_complex method.""" |
80 | | - assert SqlType.is_complex(SqlType.ARRAY) |
81 | | - assert SqlType.is_complex(SqlType.MAP) |
82 | | - assert SqlType.is_complex(SqlType.STRUCT) |
83 | | - assert SqlType.is_complex(SqlType.USER_DEFINED_TYPE) |
84 | | - assert SqlType.is_complex("ARRAY<int>") |
85 | | - assert SqlType.is_complex("MAP<string,int>") |
86 | | - assert SqlType.is_complex("STRUCT<name:string,age:int>") |
87 | | - |
88 | | - # Test non-complex types |
89 | | - assert not SqlType.is_complex(SqlType.STRING) |
90 | | - assert not SqlType.is_complex(SqlType.INT) |
91 | | - |
92 | | - |
93 | 15 | class TestSqlTypeConverter: |
94 | 16 | """Test suite for the SqlTypeConverter class.""" |
95 | 17 |
|
|
0 commit comments