PyHive icon indicating copy to clipboard operation
PyHive copied to clipboard

HiveTypeCompiler: Why 'DATE' to 'TIMESTAMP' conversion is needed

Open cabhi opened this issue 8 years ago • 3 comments

Hi

For StrictVersion(sqlalchemy.version) >= StrictVersion('0.6.0'): visit_DATE is returning 'TIMESTAMP'. Shouldn't it be DATE ?

cabhi avatar Jul 12 '17 05:07 cabhi

I'm guessing this is because PyHive predates the DATE type, which was added in 0.12. The TIMESTAMP type was added earlier.

jingw avatar Jul 15 '17 04:07 jingw

Can it be fixed now ?

cabhi avatar Jul 15 '17 07:07 cabhi

I just wonder why this is still not fixed.

I would suggest to implement this like the sqlalchemy implementation for SQL Server:

  1. a new dialect member variable, e.g. deprecated_date_type, is added which is by default False/None and can be set manually when initializing the dialect
  2. on first connection to the database, the version is read from the server via SELECT version(). When the version is older than 0.12, the deprecated_date_type variable is set to True
  3. the type compiler uses the DATE type by default and uses TIMESTAMP when deprecated_date_type is True.

Here some code snippets from the SQL Server SQLAlchemy implementation:

image

image

leo-schick avatar Nov 14 '22 15:11 leo-schick