Skip to content

Commit db971fb

Browse files
authored
Merge pull request #64 from jmcarp/compile-arrays
Compile array columns.
2 parents 2a41ed7 + ae2b896 commit db971fb

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

pybigquery/sqlalchemy_bigquery.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ def visit_text(self, type_, **kw):
205205
def visit_string(self, type_, **kw):
206206
return 'STRING'
207207

208+
def visit_ARRAY(self, type_, **kw):
209+
return "ARRAY<{}>".format(self.process(type_.item_type, **kw))
210+
208211
def visit_BINARY(self, type_, **kw):
209212
return 'BYTES'
210213

test/test_sqlalchemy_bigquery.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,16 @@ def test_compiled_query_literal_binds(engine, engine_using_test_dataset, table,
358358
assert len(result) > 0
359359

360360

361+
@pytest.mark.parametrize(["column", "processed"], [
362+
(types.String(), "STRING"),
363+
(types.NUMERIC(), "NUMERIC"),
364+
(types.ARRAY(types.String), "ARRAY<STRING>"),
365+
])
366+
def test_compile_types(engine, column, processed):
367+
result = engine.dialect.type_compiler.process(column)
368+
assert result == processed
369+
370+
361371
def test_joins(session, table, table_one_row):
362372
result = (session.query(table.c.string, func.count(table_one_row.c.integer))
363373
.join(table_one_row, table_one_row.c.string == table.c.string)

0 commit comments

Comments
 (0)