Closed
Description
Given a table, foo
, with schema:
[SchemaField('objects', 'RECORD', 'REPEATED', None, (SchemaField('object_id', 'STRING', 'NULLABLE', None, (), ()),), ())]
>>> foo = Table('foo', metadata, autoload_with=engine)
>>> print(select([func.unnest(foo.c.objects).alias('foo_objects').column]).compile(engine))
SELECT `foo_objects`
FROM unnest(`foo`.`objects`) AS `foo_objects`
BigQuery needs this select to be spelled:
SELECT foo_objects
FROM `foo`, UNNEST(`foo`.`objects`) as foo_objects
or
SELECT foo_objects
FROM `foo`, UNNEST(`objects`) as foo_objects
The
`foo`
in the FROM is needed to establish an alias for interpreting
`foo`.`objects `
or for providing a default table for
`objects `
But otherwise, there's no special requirement for the extra from
.
In particular, consider:
select x from unnest([1,2,3]) as x
which needs no extra from
because the expression given to unnest
doesn't reference a column.
The fact that unnest
takes an expression that may have 0 or more column references (from zero or more tables) makes the fix rather complicated.
(The examples above don't show a dataset, because it's set as a default.)