Add support for pushing dataframes to Presto databases.

Closes #112
This commit is contained in:
Matthew Wardrop 2017-05-10 16:03:01 -07:00 коммит произвёл Jing Wang
Родитель 0737803abb
Коммит a0f470ed17
2 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -129,7 +129,7 @@ class HiveCompiler(SQLCompiler):
return 'length{}'.format(self.function_argspec(fn, **kw))
if StrictVersion(sqlalchemy.__version__) >= StrictVersion('0.6.0'):
if StrictVersion(sqlalchemy.__version__) >= StrictVersion('0.7.0'):
class HiveTypeCompiler(compiler.GenericTypeCompiler):
def visit_INTEGER(self, type_):
return 'INT'

Просмотреть файл

@ -189,6 +189,7 @@ class PrestoDialect(default.DefaultDialect):
# requests gives back Unicode strings
return True
if StrictVersion(sqlalchemy.__version__) < StrictVersion('0.7.0'):
from pyhive import sqlalchemy_backports
@ -196,3 +197,24 @@ if StrictVersion(sqlalchemy.__version__) < StrictVersion('0.7.0'):
insp = sqlalchemy_backports.Inspector.from_engine(connection)
return insp.reflecttable(table, include_columns, exclude_columns)
PrestoDialect.reflecttable = reflecttable
else:
class PrestoTypeCompiler(compiler.GenericTypeCompiler):
def visit_CLOB(self, type_, **kw):
raise ValueError("Presto does not support the CLOB column type.")
def visit_NCLOB(self, type_, **kw):
raise ValueError("Presto does not support the NCLOB column type.")
def visit_DATETIME(self, type_, **kw):
raise ValueError("Presto does not support the DATETIME column type.")
def visit_FLOAT(self, type_, **kw):
return 'DOUBLE'
def visit_TEXT(self, type_, **kw):
if type_.length:
return 'VARCHAR({:d})'.format(type_.length)
else:
return 'VARCHAR'
PrestoDialect.type_compiler = PrestoTypeCompiler