Compiler <pyhive.sqlalchemy_hive.HiveTypeCompiler> can't render element of type <class 'sqlalchemy.sql.sqltypes.ARRAY'>
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 545
- PR merge metrics
- No merged PRs in 30d
Description
While using sqlalchemy with pyhive like this :
```python
from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
engine = create_engine("hive://@:/",connect_args={'auth': 'KERBEROS','kerberos_service_name': 'hive'})
base = declarative_base()
metadata = MetaData()
if not engine.dialect.has_table(engine, 'files'):
files = Table('files', metadata,
Column('pxx', String(3), primary_key=True),
Column('pxxxxxx', String(7), primary_key=True),
Column('record', String(60), primary_key=True),
Column('subrecord', String(60), primary_key=True),
Column('subject_id', Integer, nullable=False),
Column('type', String(1), nullable=False),
Column('signals', ARRAY(String()), nullable=False),
Column('signals', ARRAY(String()), nullable=False),
Column('startdate', DateTime, nullable=False),
Column('enddate', DateTime, nullable=False),
Column('frequency', Float, nullable=False),
Column('length_ms', BigInteger, nullable=False),
Column('date_reliability', Integer, nullable=False),
Column('init_vals', ARRAY(Float), nullable=False),
Column('block_size', ARRAY(Float), nullable=False),
Column('baseline', ARRAY(Float), nullable=False),
Column('fmt', ARRAY(String()), nullable=False),
Column('adc_zero', ARRAY(Float), nullable=False),
Column('adc_res', ARRAY(Float), nullable=False),
Column('adc_gain', ARRAY(Float), nullable=False),
Column('comments', ARRAY(String()), nullable=False),
)
metadata.create_all(engine)
```
Returns the following error :
```
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/visitors.py in _compiler_dispatch(self, visitor, **kw)
76 try:
---> 77 meth = getter(visitor)
78 except AttributeError:
AttributeError: 'HiveTypeCompiler' object has no attribute 'visit_ARRAY'
During handling of the above exception, another exception occurred:
UnsupportedCompilationError Traceback (most recent call last)
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in visit_create_table(self, create)
2481 first_pk=column.primary_key
-> 2482 and not first_pk)
2483 if processed is not None:
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in process(self, obj, **kwargs)
244 def process(self, obj, **kwargs):
--> 245 return obj._compiler_dispatch(self, **kwargs)
246
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/visitors.py in _compiler_dispatch(self, visitor, **kw)
80 else:
---> 81 return meth(self, **kw)
82 else:
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in visit_create_column(self, create, first_pk)
2512 column,
-> 2513 first_pk=first_pk
2514 )
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in get_column_specification(self, column, **kwargs)
2693 self.dialect.type_compiler.process(
-> 2694 column.type, type_expression=column)
2695 default = self.get_column_default_string(column)
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in process(self, type_, **kw)
292 def process(self, type_, **kw):
--> 293 return type_._compiler_dispatch(self, **kw)
294
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/visitors.py in _compiler_dispatch(self, visitor, **kw)
78 except AttributeError:
---> 79 raise exc.UnsupportedCompilationError(visitor, cls)
80 else:
UnsupportedCompilationError: Compiler can't render element of type
The above exception was the direct cause of the following exception:
CompileError Traceback (most recent call last)
in ()
34 Column('comments', ARRAY(String()), nullable=False),
35 )
---> 36 metadata.create_all(engine)
37
38
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/schema.py in create_all(self, bind, tables, checkfirst)
4003 self,
4004 checkfirst=checkfirst,
-> 4005 tables=tables)
4006
4007 def drop_all(self, bind=None, tables=None, checkfirst=True):
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/engine/base.py in _run_visitor(self, visitorcallable, element, connection, **kwargs)
1938 connection=None, **kwargs):
1939 with self._optional_conn_ctx_manager(connection) as conn:
-> 1940 conn._run_visitor(visitorcallable, element, **kwargs)
1941
1942 class _trans_ctx(object):
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/engine/base.py in _run_visitor(self, visitorcallable, element, **kwargs)
1547 def _run_visitor(self, visitorcallable, element, **kwargs):
1548 visitorcallable(self.dialect, self,
-> 1549 **kwargs).traverse_single(element)
1550
1551
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/visitors.py in traverse_single(self, obj, **kw)
119 meth = getattr(v, "visit_%s" % obj.__visit_name__, None)
120 if meth:
--> 121 return meth(obj, **kw)
122
123 def iterate(self, obj):
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/ddl.py in visit_metadata(self, metadata)
755 table, create_ok=True,
756 include_foreign_key_constraints=fkcs,
--> 757 _is_metadata_operation=True)
758 else:
759 for fkc in fkcs:
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/visitors.py in traverse_single(self, obj, **kw)
119 meth = getattr(v, "visit_%s" % obj.__visit_name__, None)
120 if meth:
--> 121 return meth(obj, **kw)
122
123 def iterate(self, obj):
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/ddl.py in visit_table(self, table, create_ok, include_foreign_key_constraints, _is_metadata_operation)
789 CreateTable(
790 table,
--> 791 include_foreign_key_constraints=include_foreign_key_constraints
792 ))
793
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/engine/base.py in execute(self, object, *multiparams, **params)
946 raise exc.ObjectNotExecutableError(object)
947 else:
--> 948 return meth(self, multiparams, params)
949
950 def _execute_function(self, func, multiparams, params):
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/ddl.py in _execute_on_connection(self, connection, multiparams, params)
66
67 def _execute_on_connection(self, connection, multiparams, params):
---> 68 return connection._execute_ddl(self, multiparams, params)
69
70 def execute(self, bind=None, target=None):
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/engine/base.py in _execute_ddl(self, ddl, multiparams, params)
1001 dialect=dialect,
1002 schema_translate_map=self.schema_for_object
-> 1003 if not self.schema_for_object.is_default else None)
1004 ret = self._execute_context(
1005 dialect,
in (self, bind, dialect, **kw)
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/elements.py in compile(self, default, bind, dialect, **kw)
440 else:
441 dialect = default.StrCompileDialect()
--> 442 return self._compiler(dialect, bind=bind, **kw)
443
444 def _compiler(self, dialect, **kw):
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/ddl.py in _compiler(self, dialect, **kw)
24 Dialect."""
25
---> 26 return dialect.ddl_compiler(dialect, self, **kw)
27
28
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in __init__(self, dialect, statement, bind, schema_translate_map, compile_kwargs)
217 if self.can_execute:
218 self.execution_options = statement._execution_options
--> 219 self.string = self.process(self.statement, **compile_kwargs)
220
221 @util.deprecated("0.7", ":class:`.Compiled` objects now compile "
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in process(self, obj, **kwargs)
243
244 def process(self, obj, **kwargs):
--> 245 return obj._compiler_dispatch(self, **kwargs)
246
247 def __str__(self):
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/visitors.py in _compiler_dispatch(self, visitor, **kw)
79 raise exc.UnsupportedCompilationError(visitor, cls)
80 else:
---> 81 return meth(self, **kw)
82 else:
83 # The optimization opportunity is lost for this case because the
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in visit_create_table(self, create)
2491 exc.CompileError(
2492 util.u("(in table '%s', column '%s'): %s") %
-> 2493 (table.description, column.name, ce.args[0])
2494 ))
2495
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/util/compat.py in raise_from_cause(exception, exc_info)
263 exc_type, exc_value, exc_tb = exc_info
264 cause = exc_value if exc_value is not exception else None
--> 265 reraise(type(exception), exception, tb=exc_tb, cause=cause)
266
267 if py3k:
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/util/compat.py in reraise(tp, value, tb, cause)
246 value.__cause__ = cause
247 if value.__traceback__ is not tb:
--> 248 raise value.with_traceback(tb)
249 raise value
250
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in visit_create_table(self, create)
2480 processed = self.process(create_column,
2481 first_pk=column.primary_key
-> 2482 and not first_pk)
2483 if processed is not None:
2484 text += separator
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in process(self, obj, **kwargs)
243
244 def process(self, obj, **kwargs):
--> 245 return obj._compiler_dispatch(self, **kwargs)
246
247 def __str__(self):
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/visitors.py in _compiler_dispatch(self, visitor, **kw)
79 raise exc.UnsupportedCompilationError(visitor, cls)
80 else:
---> 81 return meth(self, **kw)
82 else:
83 # The optimization opportunity is lost for this case because the
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in visit_create_column(self, create, first_pk)
2511 text = self.get_column_specification(
2512 column,
-> 2513 first_pk=first_pk
2514 )
2515 const = " ".join(self.process(constraint)
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in get_column_specification(self, column, **kwargs)
2692 colspec = self.preparer.format_column(column) + " " + \
2693 self.dialect.type_compiler.process(
-> 2694 column.type, type_expression=column)
2695 default = self.get_column_default_string(column)
2696 if default is not None:
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/compiler.py in process(self, type_, **kw)
291
292 def process(self, type_, **kw):
--> 293 return type_._compiler_dispatch(self, **kw)
294
295
~/apps/anaconda3-5.0.1/lib/python3.5/site-packages/sqlalchemy/sql/visitors.py in _compiler_dispatch(self, visitor, **kw)
77 meth = getter(visitor)
78 except AttributeError:
---> 79 raise exc.UnsupportedCompilationError(visitor, cls)
80 else:
81 return meth(self, **kw)
CompileError: (in table 'files', column 'signals'): Compiler can't render element of type
```
How can we/you fix the problem?
Thank you!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.