-
Notifications
You must be signed in to change notification settings - Fork 554
Open
Labels
Description
.description gives:
[(u'my_schema.col_one', u'BIGINT_TYPE', None, None, None, None, True),
(u'my_schema.col_two', u'DATE_TYPE', None, None, None, None, True),
(u'my_schema.col_three',
u'BIGINT_TYPE',
None,
None,
None,
None,
True)]
So the second field gives the types, but I would really like to be able to get at column types I can use in DDL statements. In this case, BIGINT, DATE, and BIGINT.
What's the best way to do this?
I see two options:
- String manipulation. Strip
_TYPEoff. - Add it to
DBAPITypeObjectby looking it up inTCLIService.constants.TYPE_NAMES:
for type_id in constants.PRIMITIVE_TYPES:
name = ttypes.TTypeId._VALUES_TO_NAMES[type_id]
setattr(sys.modules[__name__], name, DBAPITypeObject([name], constants.TYPE_NAMES[type_id]))
Then add __str__ to DBAPITypeObject which returns a valid column name for use in DDL statements.