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

update quotes #227

Merged
merged 6 commits into from
Oct 28, 2022
Merged

update quotes #227

merged 6 commits into from
Oct 28, 2022

Conversation

mhmtsrmn
Copy link
Contributor

In my production job I have had the following error:

2022-10-16 07:13:24.351003 (MainThread): �[0m07:13:24 Spark adapter: ('42000', '[42000] [Simba][Hardy] (80) Syntax or semantic analysis error thrown in server while executing query. Error message from server: org.apache.hive.service.cli.HiveSQLException: Error running query: org.apache.spark.sql.catalyst.parser.ParseException: \nextraneous input \'\' in the dbt_cloud_prod DAG.\'\' expecting {\')\', \',\'}(line 42, pos 58)\n\n== SQL ==\n/* {"app": "dbt", "dbt_version": "1. (80) (SQLExecDirectW)')

When I checked the logs I realized that the compiled SQL for dbt_artifacts.invocations was as following:

2022-10-16 07:13:24.350715 (MainThread): �[0m07:13:24 Spark adapter: Error while running:
/* {"app": "dbt", "dbt_version": "1.2.2", "profile_name": "user", "target_name": "prod", "connection_name": "master"} */

` insert into prod_analytics_artifacts.invocations

select
    col1,
    col2,
    col3,
    col4,
    col5,
    col6,
    col7,
    col8,
    col9,
    col10,
    nullif(col11, ''),
    nullif(col12, ''),
    nullif(col13, ''),
    nullif(col14, ''),
    nullif(col15, ''),
    col16,
    col17
from values
(
    '.......', 
    '1.2.2', 
    'analytics', 
    '2022-10-16 05:00:52.402202+00:00', 
    'build', 
    'True', 
    'user', 
    'prod', 
    '......', 
    256, 

    'int', 
    'int', 
    'int', 
    'other', 
    'Triggered via Apache Airflow by task 'trigger_dbt' in the dbt_cloud_prod DAG.',
        null,    
        null    
)

`

That is, when the DBT_CLOUD_RUN_REASON was referenced the airflow job id trigger_dbt in single quotes, the original single quotes that makes a call to env_var was conflicting. As a result, I changed the single quotes to double quotes.

@mhmtsrmn mhmtsrmn had a problem deploying to Approve Integration Tests October 17, 2022 21:02 Failure
@mhmtsrmn mhmtsrmn had a problem deploying to Approve Integration Tests October 17, 2022 21:02 Failure
@mhmtsrmn mhmtsrmn had a problem deploying to Approve Integration Tests October 17, 2022 21:02 Failure
@mhmtsrmn mhmtsrmn had a problem deploying to Approve Integration Tests October 17, 2022 21:02 Failure
@jeremyyeo
Copy link

Hey @mhmtsrmn - I think simply swapping the outer quotes to double quotes may not do us here because double quote strings doesn't work for all adapters/datawarehouses - Snowflake example:

image

I'm wondering if it's better to actually regex replace all single quotes in the var:

image

@NiallRees NiallRees had a problem deploying to Approve Integration Tests October 28, 2022 09:40 Failure
@NiallRees NiallRees had a problem deploying to Approve Integration Tests October 28, 2022 09:40 Failure
@NiallRees NiallRees had a problem deploying to Approve Integration Tests October 28, 2022 09:40 Failure
@NiallRees NiallRees had a problem deploying to Approve Integration Tests October 28, 2022 09:40 Failure
@NiallRees NiallRees had a problem deploying to Approve Integration Tests October 28, 2022 09:46 Failure
@NiallRees NiallRees temporarily deployed to Approve Integration Tests October 28, 2022 09:46 Inactive
@NiallRees NiallRees temporarily deployed to Approve Integration Tests October 28, 2022 09:46 Inactive
@NiallRees NiallRees temporarily deployed to Approve Integration Tests October 28, 2022 09:46 Inactive
@NiallRees NiallRees temporarily deployed to Approve Integration Tests October 28, 2022 09:53 Inactive
@NiallRees NiallRees temporarily deployed to Approve Integration Tests October 28, 2022 09:53 Inactive
@NiallRees NiallRees temporarily deployed to Approve Integration Tests October 28, 2022 09:53 Inactive
@NiallRees NiallRees temporarily deployed to Approve Integration Tests October 28, 2022 09:53 Inactive
@NiallRees NiallRees temporarily deployed to Approve Integration Tests October 28, 2022 10:00 Inactive
@NiallRees NiallRees temporarily deployed to Approve Integration Tests October 28, 2022 10:00 Inactive
@NiallRees NiallRees temporarily deployed to Approve Integration Tests October 28, 2022 10:00 Inactive
@NiallRees NiallRees temporarily deployed to Approve Integration Tests October 28, 2022 10:00 Inactive
@NiallRees
Copy link
Contributor

This is now working with a DBT_CLOUD_RUN_REASON of String with 'quotes' !

@NiallRees NiallRees merged commit f901fe3 into brooklyn-data:main Oct 28, 2022
robertholmes3 pushed a commit to robertholmes3/dbt_artifacts that referenced this pull request Nov 2, 2022
* update quotes

* Update macros/upload_invocations.sql

* Update upload_invocations.sql

* Fix bigquery quotes

* Remove snapshot from spark tests due to file type

Co-authored-by: Niall Woodward <niall@niallrees.com>
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.

3 participants