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

Cannot create tables out of SQL Select statements #68

Closed
Rahul-Gajula opened this issue Nov 9, 2021 · 14 comments
Closed

Cannot create tables out of SQL Select statements #68

Rahul-Gajula opened this issue Nov 9, 2021 · 14 comments
Assignees

Comments

@Rahul-Gajula
Copy link

  1. I am interested to know what data types for the table creation the DBT-Synapse support.
  2. Attached are the screenshots of the error what was captured while doing the runs

image
image

Out of all this I was able to generate the views from the select SQL statements against the database, but not the tables.
Note: Under dbt.project.yml i clearly defined the materialization as table to perform the action.

@dataders
Copy link
Collaborator

dataders commented Nov 9, 2021

what type of Azure synapse dedicated pools are you using: dedicated or serverless? My guess is you're using a serverless pool which do not support tables. You may want to try dbt-msft/dbt-synapse-serverless instead. Though huge caveat that serverless pools aren't that great of a solution for synapse today.

@Rahul-Gajula
Copy link
Author

Hi swanderz , could not reply you immediately.
I am using a dedicated SQL pool. No luck with table creation.
image

@dataders
Copy link
Collaborator

weird! here's some questions:

  1. what version of dbt-synapse are you using?
  2. are you using seeds or sources for these transformations?
  3. what is the column type of device_id?
  4. can you share the info from the latest run in the log (logs/dbt.log)?

@Rahul-Gajula
Copy link
Author

    • sqlserver: 0.20.1
    • synapse: 0.20.0
  1. Sources yes
    image

image
image
image
image

  1. dbt.log

@alieus
Copy link
Contributor

alieus commented Nov 10, 2021

Thanks @Rahul-Gajula. I’ll try to repro this error and see what I find

@dataders
Copy link
Collaborator

Looking at the error message I see:

Database error: ('42000', "[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The statement failed. Column 'device_id' has a data type that cannot participate in a columnstore index.

Any chance you can change your column types to not use nvarchar(max)? Not only will it not work with dbt-synapse, but it's not a good idea as it isn't very optimized.

@alieus
Copy link
Contributor

alieus commented Nov 10, 2021

@swanderz you're absolutely right. Running this directly in Synapse validates that you cannot have nvarchar(max) as a datatype:
image

However, the below works with no errors:
image

@Rahul-Gajula
Copy link
Author

Hi alieus and swanderz,

Tried creating table as per the comments. Failed yet again.

image

dbt.log

It's not even recognizing the Create Syntax

@alieus
Copy link
Contributor

alieus commented Nov 12, 2021

Hey @Rahul-Gajula , if you’d like to test this, you’d have to run it directly in your synapse workspace.

What you need to do is change the datatypes in your source tables from nvarchar(max) to nvarchar(n) and then run your select queries again in dbt.

@Rahul-Gajula
Copy link
Author

Hi alieus,

Even with the data type nvarchar(n) i am not able to create a table.

CREATE TABLE telemetry_test(
device_id NVARCHAR(n),
IP_adress NVARCHAR(n)
);

@alieus
Copy link
Contributor

alieus commented Nov 12, 2021

where n is the size of the string in byte-pairs. For example, nvarchar(16).

@Rahul-Gajula
Copy link
Author

Hi alieus,

Even that i tried. refer to the screen shot.
image

@Rahul-Gajula
Copy link
Author

Hi alieus and swanderz,

i figured out the solution for it. i need to change my data type to make it work. Using convert operator in the sql syntax worked.

image

Thank you for your kind help. you may close the ticket.

@dataders
Copy link
Collaborator

Glad to hear it! I’m sure this issue will definitely help someone else in the future.

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

No branches or pull requests

3 participants