-
Notifications
You must be signed in to change notification settings - Fork 406
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
Error when formatting Spark SQL #746
Comments
Thanks for reporting.
|
@liyuanhao6 if you are using VSCode try: "SQL-Formatter-VSCode.paramTypes": {
"custom": [
{
"regex": "\\$?\\{[a-zA-Z0-9_]+\\}"
}
]
}, for the second problem. |
@amadeuspzs Thank you for the fix! Interesting though, that I could format my sparksql code without this fix in the settings. --- code before formatting:
create or replace view ${unity_catalog_name}.${environment_name}_sublayer.tablename
--- code after formatting:
create or replace view ${unity_catalog_name}.${environment_name} _sublayer.tablename -- whitespace appears after closing '}' |
Yeah, this However the formatter assumes that CREATE ${orReplace} ${entity} ${type}; But really I know very little about Spark. I'm not even sure if this |
We're using The additional whitespace looks like a result of nene's explanation that the formatter assumes it's an identifier, rather than a general purpose string replacement. This is why whitespace isn't introduced after a ${one}.${two} whereas ${one}_${two} becomes ${one} _ ${two} One workaround would be to use/derive a "whole word" parameter instead of partial one e.g. spark.conf.set("environment_name_sublayer", f"{environment_name}_sublayer") followed by create or replace view ${unity_catalog_name}.${environment_name_sublayer}.tablename which yields CREATE OR REPLACE VIEW ${unity_catalog_name}.${environment_name_sublayer}.tablename |
First Bug
Unable to format SQL: Error: Parse error: Unexpected "8g; set li" at line 1 column 50
We usually use the Spark configurations in the SQL codes, and it reports the bug. We suppose those configurations are useful, and could you please help us fix this bug?
Second Bug
Unable to format SQL: Error: Parse error: Unexpected "${v_day} )" at line 112 column 17
We usually use shell parameter in the SQL codes, and it reports the bug. We suppose those parameters are useful, and could you please help us fix this bug?
The text was updated successfully, but these errors were encountered: