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

why presto don't support implicit conversion from number to varchar ? #10888

Closed
xingnailu opened this issue Jun 21, 2018 · 5 comments
Closed

Comments

@xingnailu
Copy link

xingnailu commented Jun 21, 2018

my create table statement are:

CREATE TABLE `address`(
  `x` int, 
  `y` int);

and when I query use :

    select * from address where x = '1'    

I got an exception like

  com.facebook.presto.sql.analyzer.SemanticException: line 1:8: Cannot cast integer to char(1)
	at com.facebook.presto.sql.analyzer.ExpressionAnalyzer$Visitor.visitCast(ExpressionAnalyzer.java:944)
	at com.facebook.presto.sql.analyzer.ExpressionAnalyzer$Visitor.visitCast(ExpressionAnalyzer.java:288)
	at com.facebook.presto.sql.tree.Cast.accept(Cast.java:98)

but. hive support this implicit conversion.
does presto want to do this ? if not , why?
thx !

@xingnailu xingnailu changed the title why presto why presto don't support implicit conversion from number to varchar ? Jun 21, 2018
@findepi
Copy link
Contributor

findepi commented Jun 21, 2018

@xingnailu just curious, what Presto version is this? Mine says line 1:31: '=' cannot be applied to integer, varchar(1) ('a' is currently considered a varchar(1) rather than char(1)).

If there was the implicit conversion integer -> varchar, the end result wouldn't be that nice anyway. Note that operations, including comparisons, on varchars are slower than on numbers.

Of course, this doesn't mean such a coercion should not exist. The SQL standard governs that, but I didn't check it

@xingnailu
Copy link
Author

@findepi I am glad to receive you replication. And my presto version is 0.192. Can I consider the reason that presto don't implicit conversion integer to varchar is efficiency. I think I will do this implicit conversion by myself.
thx

@findepi
Copy link
Contributor

findepi commented Jun 21, 2018

Can I consider the reason that presto don't implicit conversion integer to varchar is efficiency.

No, it's not.
I was just saying that, in case of your query, such an implicit conversion would be detrimental to performance.

@hereTac
Copy link

hereTac commented Sep 14, 2018

May be all the Hive users want this features. @findepi . It take huge cost changes for rewrite Hive scripts. Hive‘s market is so huge(ETL). Why not consider fully supporting Hive? This is more conducive to the development of Presto. Presto can increase the indication that opening this feature will reduce performance.

@UpAndDowns
Copy link

我也遇到了相同的问题,希望各位大佬给出解决的方案,非常感谢

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

4 participants