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

Fixing MERGE to use named paths in table names #223

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bony2023
Copy link

Closes: goccy/bigquery-emulator#299

The sub-actions (INSERT, UPDATE and DELETE) inside the merge statement currently do not work when using BigQuery Emulator, as they are not able to recognize the exact table they need to work upon.

This PR fixes the logic by adding namePath to the source and target table names joined by underscore to work on sqlite tables.

@bony2023 bony2023 force-pushed the br-fix-merge-table-name branch from b9fc619 to 449471d Compare September 16, 2024 17:12
@bony2023 bony2023 changed the title Fix MERGE handling named paths Fixing MERGE to use named paths in table names Sep 16, 2024
@n10l
Copy link

n10l commented Sep 16, 2024

Hi @bony2023,
Thanks for your changes. Even though the unit tests are passing, still its not generating expected query including project id and dataset with emulator. Its sending query without project id and dataset in emulator and raising same error:
no such table: <table_name_without_dataset>.
Even I tried with same query as in tests as well.

@bony2023
Copy link
Author

I believe it's because the emulator always pass the datasetID as empty when executing a Query.

I'll see if I can fix it here directly.

@n10l
Copy link

n10l commented Sep 16, 2024

Thanks @bony2023 for all the help.

@n10l
Copy link

n10l commented Sep 16, 2024

Thanks @bony2023 for your last message. You are right and I confirm, by hard coding namePath[1] to my dataset name in your changes in this PR, everything works as expected in local emulator 🎉🎉. I am not sure if fixing this right way is possible in this lib, but thanks for being the savior here. I am new to BQ as well as Go, and was trying to figure this out for last two days, and you saved me here.

@bony2023 bony2023 force-pushed the br-fix-merge-table-name branch from 449471d to 5d04344 Compare September 16, 2024 20:12
@bony2023
Copy link
Author

I just pushed a commit to extract datasetID if it's not provided in namePath from the emulator.

@bony2023 bony2023 force-pushed the br-fix-merge-table-name branch from 5d04344 to 9a668f1 Compare September 16, 2024 20:22
@bony2023 bony2023 force-pushed the br-fix-merge-table-name branch from 9a668f1 to a319e2e Compare September 16, 2024 20:43
@n10l
Copy link

n10l commented Sep 17, 2024

@bony2023 Sorry for delay in responding. Your latest commit works very well. Thank you so much. 🎉🎉🎉🎉🎉

@nealrushforthlbg
Copy link

when will this be merged?

@Ojasv-Singh-Zeotap
Copy link

Any updates here? failed to exec merge statement CREATE TABLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failes to exec merge statement UPDATE
4 participants