Skip to content

Commit c5d97bd

Browse files
remove TYPE_NAME mapping
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 61a9200 commit c5d97bd

File tree

3 files changed

+34
-39
lines changed

3 files changed

+34
-39
lines changed

src/databricks/sql/backend/column_mapping.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,14 @@ class MetadataOp(Enum):
4444
}
4545

4646
# ref: COLUMN_COLUMNS in JDBC: https://github.com/databricks/databricks-jdbc/blob/e3d0d8dad683146a3afc3d501ddf0864ba086309/src/main/java/com/databricks/jdbc/common/MetadataResultConstants.java#L192
47+
# TYPE_NAME is not included because it is a duplicate target for columnType, and COLUMN_DEF is known to be returned by Thrift.
48+
# TODO: check if TYPE_NAME is to be returned / also used by Thrift.
4749
COLUMN_COLUMNS = {
4850
"catalogName": "TABLE_CAT",
4951
"namespace": "TABLE_SCHEM",
5052
"tableName": "TABLE_NAME",
5153
"col_name": "COLUMN_NAME",
5254
"dataType": "DATA_TYPE",
53-
"columnType": "TYPE_NAME",
5455
"columnSize": "COLUMN_SIZE",
5556
"bufferLength": "BUFFER_LENGTH",
5657
"decimalDigits": "DECIMAL_DIGITS",

tests/unit/backend/test_column_mapping.py

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
from databricks.sql.backend.column_mapping import (
1010
normalise_metadata_result,
1111
MetadataOp,
12-
CATALOG_OP,
13-
SCHEMA_OP,
14-
TABLE_OP,
15-
COLUMN_OP,
1612
)
1713

1814

@@ -95,25 +91,24 @@ def test_normalize_metadata_result_columns(self):
9591
("catalogName", "string", None, None, None, None, True),
9692
("namespace", "string", None, None, None, None, True),
9793
("tableName", "string", None, None, None, None, True),
98-
("columnName", "string", None, None, None, None, True),
94+
("col_name", "string", None, None, None, None, True),
9995
("dataType", "string", None, None, None, None, True),
100-
("columnType", "string", None, None, None, None, True),
10196
("columnSize", "string", None, None, None, None, True),
10297
("bufferLength", "string", None, None, None, None, True),
10398
("decimalDigits", "string", None, None, None, None, True),
10499
("radix", "string", None, None, None, None, True),
105-
("nullable", "string", None, None, None, None, True),
100+
("Nullable", "string", None, None, None, None, True),
106101
("remarks", "string", None, None, None, None, True),
107-
("columnDef", "string", None, None, None, None, True),
108-
("sqlDataType", "string", None, None, None, None, True),
109-
("sqlDatetimeSub", "string", None, None, None, None, True),
110-
("charOctetLength", "string", None, None, None, None, True),
102+
("columnType", "string", None, None, None, None, True),
103+
("SQLDataType", "string", None, None, None, None, True),
104+
("SQLDatetimeSub", "string", None, None, None, None, True),
105+
("CharOctetLength", "string", None, None, None, None, True),
111106
("ordinalPosition", "string", None, None, None, None, True),
112107
("isNullable", "string", None, None, None, None, True),
113-
("scopeCatalog", "string", None, None, None, None, True),
114-
("scopeSchema", "string", None, None, None, None, True),
115-
("scopeTable", "string", None, None, None, None, True),
116-
("sourceDataType", "string", None, None, None, None, True),
108+
("ScopeCatalog", "string", None, None, None, None, True),
109+
("ScopeSchema", "string", None, None, None, None, True),
110+
("ScopeTable", "string", None, None, None, None, True),
111+
("SourceDataType", "string", None, None, None, None, True),
117112
("isAutoIncrement", "string", None, None, None, None, True),
118113
("isGenerated", "string", None, None, None, None, True),
119114
("other_column", "string", None, None, None, None, True),
@@ -128,26 +123,25 @@ def test_normalize_metadata_result_columns(self):
128123
assert mock_result.description[2][0] == "TABLE_NAME"
129124
assert mock_result.description[3][0] == "COLUMN_NAME"
130125
assert mock_result.description[4][0] == "DATA_TYPE"
131-
assert mock_result.description[5][0] == "TYPE_NAME"
132-
assert mock_result.description[6][0] == "COLUMN_SIZE"
133-
assert mock_result.description[7][0] == "BUFFER_LENGTH"
134-
assert mock_result.description[8][0] == "DECIMAL_DIGITS"
135-
assert mock_result.description[9][0] == "NUM_PREC_RADIX"
136-
assert mock_result.description[10][0] == "NULLABLE"
137-
assert mock_result.description[11][0] == "REMARKS"
138-
assert mock_result.description[12][0] == "COLUMN_DEF"
139-
assert mock_result.description[13][0] == "SQL_DATA_TYPE"
140-
assert mock_result.description[14][0] == "SQL_DATETIME_SUB"
141-
assert mock_result.description[15][0] == "CHAR_OCTET_LENGTH"
142-
assert mock_result.description[16][0] == "ORDINAL_POSITION"
143-
assert mock_result.description[17][0] == "IS_NULLABLE"
144-
assert mock_result.description[18][0] == "SCOPE_CATALOG"
145-
assert mock_result.description[19][0] == "SCOPE_SCHEMA"
146-
assert mock_result.description[20][0] == "SCOPE_TABLE"
147-
assert mock_result.description[21][0] == "SOURCE_DATA_TYPE"
148-
assert mock_result.description[22][0] == "IS_AUTOINCREMENT"
149-
assert mock_result.description[23][0] == "IS_GENERATEDCOLUMN"
150-
assert mock_result.description[24][0] == "other_column"
126+
assert mock_result.description[5][0] == "COLUMN_SIZE"
127+
assert mock_result.description[6][0] == "BUFFER_LENGTH"
128+
assert mock_result.description[7][0] == "DECIMAL_DIGITS"
129+
assert mock_result.description[8][0] == "NUM_PREC_RADIX"
130+
assert mock_result.description[9][0] == "NULLABLE"
131+
assert mock_result.description[10][0] == "REMARKS"
132+
assert mock_result.description[11][0] == "COLUMN_DEF"
133+
assert mock_result.description[12][0] == "SQL_DATA_TYPE"
134+
assert mock_result.description[13][0] == "SQL_DATETIME_SUB"
135+
assert mock_result.description[14][0] == "CHAR_OCTET_LENGTH"
136+
assert mock_result.description[15][0] == "ORDINAL_POSITION"
137+
assert mock_result.description[16][0] == "IS_NULLABLE"
138+
assert mock_result.description[17][0] == "SCOPE_CATALOG"
139+
assert mock_result.description[18][0] == "SCOPE_SCHEMA"
140+
assert mock_result.description[19][0] == "SCOPE_TABLE"
141+
assert mock_result.description[20][0] == "SOURCE_DATA_TYPE"
142+
assert mock_result.description[21][0] == "IS_AUTOINCREMENT"
143+
assert mock_result.description[22][0] == "IS_GENERATEDCOLUMN"
144+
assert mock_result.description[23][0] == "other_column"
151145

152146
def test_normalize_metadata_result_unknown_operation(self):
153147
"""Test normalizing with an unknown operation type."""

tests/unit/test_sea_backend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,10 +869,10 @@ def test_get_columns(self, sea_client, sea_session_id, mock_cursor):
869869
("catalogName", "string", None, None, None, None, True),
870870
("namespace", "string", None, None, None, None, True),
871871
("tableName", "string", None, None, None, None, True),
872-
("columnName", "string", None, None, None, None, True),
872+
("col_name", "string", None, None, None, None, True),
873873
("columnType", "string", None, None, None, None, True),
874874
("dataType", "string", None, None, None, None, True),
875-
("nullable", "string", None, None, None, None, True),
875+
("Nullable", "string", None, None, None, None, True),
876876
("isNullable", "string", None, None, None, None, True),
877877
("ordinalPosition", "string", None, None, None, None, True),
878878
]
@@ -907,7 +907,7 @@ def test_get_columns(self, sea_client, sea_session_id, mock_cursor):
907907
assert result.description[1][0] == "TABLE_SCHEM"
908908
assert result.description[2][0] == "TABLE_NAME"
909909
assert result.description[3][0] == "COLUMN_NAME"
910-
assert result.description[4][0] == "TYPE_NAME"
910+
assert result.description[4][0] == "COLUMN_DEF"
911911
assert result.description[5][0] == "DATA_TYPE"
912912
assert result.description[6][0] == "NULLABLE"
913913
assert result.description[7][0] == "IS_NULLABLE"

0 commit comments

Comments
 (0)