-
Notifications
You must be signed in to change notification settings - Fork 138
Unable compare value from records array #233
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
Comments
@fallncrlss could you please share the SQLAlchemy model definitions you used for the code examples? |
In my case, due to some limitations of business logic, I should define SQLAlchemy BQ models dynamically like the example below: from sqlalchemy import create_engine, Table, MetaData
engine = create_engine('BQ_CONNECTION_URL', pool_size=POOL_SIZE)
SomeTable = Table('some_table_name', MetaData(bind=engine), autoload=True) |
@fallncrlss please share the code you used to define Mock and AnotherMock (or whatever you actually named them). I think I know what's going on, but being able to reproduce what you did exactly would help to be sure and reduce the chance of wasting everyone's time. |
There are two issues.
|
Mock and AnotherMock model schemas define directly in BigQuery, and in the code I define them dynamically as in the example above using |
OK, fair enough. Then I think I reproduced your scenario. |
More info on what I said about using Some references invoking functions like unnest:
See: https://docs.sqlalchemy.org/en/14/tutorial/data_select.html#tutorial-functions-table-valued |
Well, that doesn't work either. :( #293 |
@fallncrlss see python-bigquery-sqlalchemy/tests/system/test__struct.py Lines 158 to 166 in f6d2799
for an example of how to do what you want to do with sqlalchemy-bigquery 1.2.0 or later. Note that dot notation now works if the name doesn't conflict with an internal name, so:
and if there's a chance of a conflict, you can use upper case to disambiguate:
|
I need to create a join of 2 BQ tables where one of them has an
id
field that has to be compared with the record id in the repeated field (array of records) of another one. I'm struggling with SQLAlchemy implementation of the SQL query that works fine. Tried to solve this problem in different ways, but nothing was successful, most relevant and similar to sql-like solution below. Probably, there are some troubles with sqlalchemy interpretation of SQL queries or result fetch either, aren't?Environment details
google-cloud-bigquery
version: 2.22.1Steps to reproduce
Create the BQ table
Mock
with fields:mock_id
| type:STRING
| mode:NULLABLE
Create the BQ table
AnotherMock
with fields:objects
| type:RECORD
| mode:REPEATED
object_id
| type:STRING
| mode:NULLABLE
Run code below (It gonna fail).
Run SQL below (it gonna success).
SQL example
Code example
Stack trace
AttributeError: 'Comparator' object has no attribute 'object_id'
The text was updated successfully, but these errors were encountered: