Skip to content

Commit

Permalink
add HiveDate datatype
Browse files Browse the repository at this point in the history
  • Loading branch information
mrocklin committed Jan 5, 2015
1 parent 80a2644 commit 3a6ad95
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pyhive/sqlalchemy_hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ def process_bind_param(self, value, dialect):
raise NotImplementedError("Writing to Hive not supported")


class HiveDate(HiveStringTypeBase):
"""Translates date strings to date objects"""
impl = types.DATE

def process_result_value(self, value, dialect):
return processors.str_to_date(value)


class HiveTimestamp(HiveStringTypeBase):
"""Translates timestamp strings to datetime objects"""
impl = types.TIMESTAMP
Expand Down Expand Up @@ -334,6 +342,7 @@ def __init__(self, dialect):
'float': types.Float,
'double': types.Float,
'string': types.String,
'date': HiveDate,
'timestamp': HiveTimestamp,
'binary': types.String,
'array': types.String,
Expand Down Expand Up @@ -377,6 +386,7 @@ class HiveDialect(default.DefaultDialect):
returns_unicode_strings = True
description_encoding = None
dbapi_type_map = {
'DATE_TYPE': HiveDate(),
'TIMESTAMP_TYPE': HiveTimestamp(),
'DECIMAL_TYPE': HiveDecimal(),
}
Expand Down

0 comments on commit 3a6ad95

Please sign in to comment.