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

add method 'toChar[class java.lang.Object]' in class class org.apach… #3752

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pierre-mazieres-semarchy

When I was working on a dummy Apache Connector (in order to understand how to use this framework),
I encountered this error:

Suppressed: java.lang.RuntimeException: while resolving method 'toChar[class java.lang.Object]' in class class org.apache.calcite.runtime.SqlFunctions
Caused by: java.lang.NoSuchMethodException: org.apache.calcite.runtime.SqlFunctions.toChar(java.lang.Object)

So I added the required method: org.apache.calcite.runtime.SqlFunctions.toChar(java.lang.Object)

For information, there are already many similar methods for other primitive types (int, bool ...).
So the new toChar(Object) method is similar to those other primitive methods

@mihaibudiu
Copy link
Contributor

Can you also provide a test which fails in the absence of this function?

@pierre-mazieres-semarchy
Copy link
Author

@mihaibudiu
There is no Junit class for the SqlFunctions class yet.
I will create one and update this PR.

@mihaibudiu
Copy link
Contributor

No, not unit tests. An end-to-end test is more valuable. Like something with your dummy connector.

@pierre-mazieres-semarchy
Copy link
Author

OK, I probably can extract a simple snippet in order to reproduce the issue.

But how should I send it to you ?
In a dummy Java class with a main function ?

@mihaibudiu
Copy link
Contributor

Do write a junit test, but not a unit test for toChar.
You will have to figure out where the test belongs, though (which of the many test files).
I have never used connectors in my code, so I am not sure where they should be tested.

@mihaibudiu
Copy link
Contributor

If you can post here a failing snippet I can perhaps try to look around the codebase to see where similar stuff is tested.

@pierre-mazieres-semarchy
Copy link
Author

pierre-mazieres-semarchy commented Apr 5, 2024

I added a snippet.

In order to reproduce the original issue:

  • Comment the new toChar(Object) method
  • In the PrimitiveTest class, run the testUpdate method

The bug is triggered in:

  • the PrimitiveTest.testUpdate method on line 37 when running the UPDATE statement: statement.executeUpdate("UPDATE DUMMY.PRIMITIVE SET INT_=1")
  • it will call the InMemoryEnumerableTableModify.implement method on line 74 when i=1: childPhysType.fieldReference(o_, i, javaFieldType)
  • and then try to call the toChar(Object) method

If you uncomment the toChar(Object) method,
There will be no issue, and the UPDATE statement will be effective.

@mihaibudiu
Copy link
Contributor

Sorry, busy with many reviews for the 1.37 release, didn't have time to properly look at this.
Hope to get back to it soon.

@pierre-mazieres-semarchy
Copy link
Author

pierre-mazieres-semarchy commented Apr 10, 2024

Hello @mihaibudiu
No problem, take your time.
It is not a big deal on my side,
I made a quick & dirty workaround on my dummy project.
Apache Calcite is not my main project,
so I also can not work on it on full time :D

Copy link
Contributor

@mihaibudiu mihaibudiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to create a smaller reproduction and I failed.
I guess we could accept this change without a test...
Or a very involved one, like the one you wrote.
I am inclined to suggest for you to just submit a PR with the new toChar function.

Copy link

github-actions bot commented Dec 5, 2024

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants