Dataform - handling duplicate table names

This feels like something I’ve overlooked, but I’m having trouble with two tables that have the same name. I have two Google Search Console accounts pushing data to BigQuery. They have different dataset names, but the tables in each are all named the same.

When I add both of these sources in Dataform (as I want to join them) they generate the same table name, searchdata_url_impression, and then I have conflict name issues when I use

${ref(“searchdata_url_impression”)} in my SQLX models, with the error “Ambiguous Action name: searchdata_url_impression.”

I’ve tried changing my source declarations to SQLX files and then adding the publish option to create an alias, but this didn’t work and the SQL models didn’t pick it up.

Any thoughts?

1 Like

You can qualify a dataset and a table with a comma in the ${ref()} call.

ex.
${ref(“”, “<table_name>”)}
${ref(“<dataset_1>”, “<searchdata_url_impression>”)}

3 Likes

Legend. That’s resolved the issue. I knew it was something so incredibly obvious! :sweat_smile:

can we get that dataset name from a const variable?

${ref(“<dataset_1>”, “<searchdata_url_impression>”)}

1 Like

And how does it work for dependencies option in JS?
E.g. I have two tables: staging.pages and all.pages
In a publish I need to reference one of them as a dependency, so I do:

publish('meta', {
  type: 'table',
  schema: 'reports',
  dependencies: ['pages']
}).query(
...

At this point I get an error:

Ambiguous Action name: {“name”:“pages”,“includeDependentAssertions”:false}. Did you mean one of: all.pages, staging.pages.

If I try to fix it:

publish('meta', {
  type: 'table',
  schema: 'reports',
  dependencies: ['all.pages']
}).query(
...

I get a new one:

Missing dependency detected: Action “httparchive.scratchspace.meta_crawl” depends on “{“name”:“all.pages”,“includeDependentAssertions”:false}” which does not exist

Is it solvable with JS syntax?

1 Like