Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sqlalchemy_hive.py #447

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions pyhive/sqlalchemy_hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@

import re
from sqlalchemy import exc
from sqlalchemy import processors
try:
from sqlalchemy import processors
except ImportError:
# Newer versions of sqlalchemy require:
from sqlalchemy.engine import processors
from sqlalchemy import types
from sqlalchemy import util
# TODO shouldn't use mysql type
from sqlalchemy.databases import mysql
try:
from sqlalchemy.databases import mysql
except ImportError:
# Newer versions require import from dialects not databases
from sqlalchemy.dialects import mysql
from sqlalchemy.engine import default
from sqlalchemy.sql import compiler
from sqlalchemy.sql.compiler import SQLCompiler
Expand Down Expand Up @@ -121,7 +129,6 @@ def __init__(self, dialect):

_type_map = {
'boolean': types.Boolean,
'tinyint': mysql.MSTinyInteger,
'smallint': types.SmallInteger,
'int': types.Integer,
'bigint': types.BigInteger,
Expand All @@ -140,6 +147,16 @@ def __init__(self, dialect):
'decimal': HiveDecimal,
}

try:
_type_map.update({
'tinyint': mysql.MSTinyInteger
})
except AttributeError:
# Support for version 2.x of sqlalchemy
_type_map.update({
'tinyint': mysql.base.MSTinyInteger
})


class HiveCompiler(SQLCompiler):
def visit_concat_op_binary(self, binary, operator, **kw):
Expand Down