Skip to content

Want STRING but got TEXT #3493

Closed Answered by georgesittas
madeirak asked this question in Q&A
Discussion options

You must be logged in to vote

They are converted into TEXT because you didn't supply an output dialect. My guess is that you're doing str(ast) which invokes the .sql() method without a dialect. Try ast.sql("spark") or transpile(sql, "spark").

>>> import sqlglot
>>> sqlglot.transpile("cast(x as string)", "spark")
['CAST(x AS STRING)']

Check out https://github.com/tobymao/sqlglot/blob/main/posts/ast_primer.md

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by georgesittas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants