-
Notifications
You must be signed in to change notification settings - Fork 703
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
Presto bugs #963
Comments
presto also supports concat_ws, not only trino. It's not in the documentations, but it's in the code and it works: https://github.com/prestodb/presto/search?q=concat_ws |
@evyasonov thanks will update |
5, 6, 7 cddac1b |
8, 9 650e123 |
10 a1fb957 |
11 57eb2ce |
12, 13 4ba4694 |
14 588064e |
15 2c8a413 |
16 won't fix, sqlglot is not a validator |
Why not leave it as it is? I mean transform |
because | is not valid in presto, so | makes it into the user intent |
Not agree. A user might easily misspell | with || which is valid in presto, so his intention is concat in this case. The best option is to leave it as it is. While |
23 is won't fix, only remaining issue is 17 which will be fixed later |
@tobymao Also, can you please explain why not to fix 22? I mean it works when it reads from spark, but does not work for presto. What is the problem? |
@georgesittas is looking at 19, but sqlglot is best effort with comments, we'll try to improve it but it won't get everything like group /* x */ by will never be supported with 22, although presto doesn't support select 1a, sqlglot does and is more leniant |
@tobymao |
in spark, 1a is valid column syntax |
@tobymao 24 |
@tobymao |
depends on the engine, many engines do select 1a == select 1 as a |
In case of presto transpiling |
Also, in case if it's something like Does "other" engines do do select 1e1a1a == select 1 as e1a1a or == select 1e1 as a1a? |
transpiling SQL is extremely difficult. the current behavior matches postgres which is a pretty good standard. i'm not inclined to change this behavior right now, sorry. in order for this project to be maintainable, we need to pick and choose our battles. in this case, i think the current behavior is fine. |
ok,,, will create a new dialect called "my logical presto" this way:
which will resolve risky behaviour |
also, can you tell what should I add into "my logical presto" so it won't change | into bitwise_or? |
that's a great solution |
one way is to error by doing Parser: |
like this
? |
yea, then it should raise when you do x | y |
ok, thx |
P.S. and what about bug 24?) |
@georgesittas any update regarding 19? |
nope |
I've looked at 19 and I don't think it's worth fixing. Most of these comments are placed in bizarre spots that you wouldn't normally expect them to be, and others (such as the one following the The way we've approached comments, there will always be cases that won't be handled correctly. It's a hard problem to solve completely, and as Toby mentioned in a previous message, SQLGlot follows a best-effort approach; it prioritizes preserving comments that are more frequent, e.g. in projection lists, table references in a FROM clause, etc. |
@georgesittas My motivation here is that most of users don't expect that anything might be deleted from their queries without letting know. Especially if it's done in semi-automatic mode or automatic mode, so users don't review the output. It will solve both 19 and 20. What do you think? @tobymao |
That's not really any better. Especially for big queries, the comments will be moved out of context and they will essentially be useless. The point is to try and maintain the context in which they appear. |
@georgesittas From my point of view, this is the priorities:
What do you think? |
This is not a priority right now, maybe we'll revisit this at some point in the future. |
ok
Input:
select approx_percentile(a, b, c, d)
Output:The number of provided arguments (4) is greater than the maximum number of supported arguments (3). Line 1, Col: 36. select approx_percentile(a, b, c, d)
4 arguments are possible: https://prestodb.io/docs/current/functions/aggregate.html
ok
Input:
select concat_ws(a, b)
Output:select array_join(b, a)
convcat_ws
has two signatures, replacing it with array_join is not correct for the case when all arguments are strings, such asselect concat_ws('a', 'b', 'c')
: https://trino.io/docs/current/functions/string.htmlok
Input:
select from_unixtime(a, b, c)
Output:The number of provided arguments (3) is greater than the maximum number of supported arguments (2). Line 1, Col: 29. select from_unixtime(a, b, c)
3 arguments are possible: https://prestodb.io/docs/current/functions/datetime.html
ok
Input:
select from_utf8(a, b)
Output:select from_utf8(a)
Two arguments are possible, the second argument can not be ignored: https://prestodb.io/docs/current/functions/string.html
ok
Input:
select greatest(a)
Output:Required keyword: 'expressions' missing for <class 'sqlglot.expressions.Greatest'>. Line 1, Col: 18. select greatest(a)
Input is valid both
select greatest(1)
andselect greatest(a) FROM (values 1) as t(a)
worksok
Input:
select least(a)
Output:Required keyword: 'expressions' missing for <class 'sqlglot.expressions.Least'>. Line 1, Col: 15. select least(a)
Input is valid both
select least(1)
andselect least(a) FROM (values 1) as t(a)
worksok
Input:
select map()
Output:Required keyword: 'keys' missing for <class 'sqlglot.expressions.Map'>. Line 1, Col: 12. select map()
Input is valid, it returns an empty map
ok
Input:
select max(a, b)
Output:The number of provided arguments (2) is greater than the maximum number of supported arguments (1). Line 1, Col: 16. select max(a, b)
Two arguments are possible: https://prestodb.io/docs/current/functions/aggregate.html
ok
Input:
select min(a, b)
Output:The number of provided arguments (2) is greater than the maximum number of supported arguments (1). Line 1, Col: 16. select min(a, b)
Two arguments are possible: https://prestodb.io/docs/current/functions/aggregate.html
ok
Input:
select strpos(a, b)
Output:select strpos(b, a)
Order of arguments should not be changed
ok
Input:
select trim(a, b)
Output:Expecting ). Line 1, Col: 14. select trim(a, b)
Unexpected error. Two arguments are not documented, but
select trim('abaassqweabab', 'ab')
works. And in `SHOW FUNCTIONS' it's told thatok
Input:
select truncate(a, b)
Output:select truncate as (a, b)
Wrong output
ok
Input:
select truncate(a)
Output:select truncate as (a)
Wrong output
ok
Input:
select var_pop(a)
Output:select variance_pop(a)
There's no such function as
variance_pop
: https://prestodb.io/docs/current/functions/aggregate.htmlok
Input:
select strpos(a, b, c)
Output:select strpos(substr(b, c), a) + c - 1
Wrong output.
select strpos('a a a a', 'a', 3)
returns 5 whileselect strpos(substr('a', 3), 'a a a a') + 3 - 1
return 2.The
strpos
should not be changed at all.might be fixed by creating custom dialect
Input:
select a | b
Output:select bitwise_or(a, b)
Should rise an error, because there's no | in presto.
ok
Input
print(sqlglot.transpile("select a from (select '1\n2' as a)", read="presto", write="presto", pretty=True)[0])
, Output:Should not indent multiline strings
ok
Input
CREATE TABLE asd AS SELECT asd FROM asd WITH NO DATA
Output: errorShould work correctly
?
Input
Output
Should not delete comments 4, 8, 9 11, 22, 23, 25, 26, 28, 31
declined
Input
SELECT bool_or(a> 10) FROM asd AS T(a) GROUP /* asd */ BY GROUPING SETS(())
Output errorInput is valid, should work in case comments are presented beween special keywords
ok
Input
SELECT bool_or(a> 10) FROM (values 1, 2, 15) AS T(a)
Output errorInput is valid
might be fixed by creating custom dialect
Input
print(sqlglot.transpile("SELECT 1a", read="spark", write="presto", pretty=False)[0])
works correctly, whileprint(sqlglot.transpile("SELECT 1a", read="presto", write="presto", pretty=False)[0])
returns wrong answer.declined
Input
SELECT row()
Output errorSELECT row()
Presto returns
Function row not registered
, so the parser also should throw an error?
Input
print(sqlglot.transpile("select 1a as 1a", read="spark", write="presto", pretty=False)[0])
Outputselect 1a as 1a
It transpiles valid spark sql into non-valid presto sql
Hint
You can probably use
SHOW FUNCTIONS
to get all available functions and check other dialects. You can use the script belowThe text was updated successfully, but these errors were encountered: