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

Casting to sa.Float (and some other types) silently does nothing #151

Closed
DelongChenQC opened this issue Dec 6, 2024 · 4 comments
Closed

Comments

@DelongChenQC
Copy link

When explicitly using the cast function to cast something into a sa.Float, the engine silently ignores this command and instead does nothing. This is especially dangerous when working with bind parameters as the implicit casting, does not work.
E.g:

metadata = sa.MetaData()
table = sa.Table(table_input, metadata, schema=schema_name, autoload_with=engine)

int_column_1 = table.int_column_1
int_column_2 = table.int_column_2

problem_query = sa.cast(int_column_1 / int_column_2, sa.Float) / 1_000_000

When now executing this query, one would expect a float outcome, however due to the way the

def visit_cast(self, cast, **kw):
function is written. It throws out the casting, leading to a silent error.

What is the reasoning for only having a set number of types that casting is possible to?

@bchoudhary6415
Copy link
Collaborator

Hello @DelongChenQC 
Thank you for pointing it out.
I will add the float datatype for casting. 
Can you please suggest the names of some other datatypes that require casting?
So that we don't miss the required datatypes.

Thank you.

@bchoudhary6415
Copy link
Collaborator

bchoudhary6415 commented Dec 23, 2024

Hello @DelongChenQC

Fix for this issue is given with PR - #154
Please review and verify the solution.

Thank you

bimalkjha pushed a commit that referenced this issue Dec 23, 2024
@bchoudhary6415
Copy link
Collaborator

Hello @DelongChenQC

Fix for this with PR - #154 is merged now.
Closing the issue.

Thank you.

@DelongChenQC
Copy link
Author

Thanks very much, sorry for the late answer, but LGTM 😄

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

2 participants