zeppelin icon indicating copy to clipboard operation
zeppelin copied to clipboard

[ZEPPELIN-6131] Error occurred when modifying Elasticsearch interpreter port

Open ParkGyeongTae opened this issue 1 year ago • 1 comments

What is this PR for?

There was an issue where the port was treated as a string and included .0 when modifying the port of the Elasticsearch interpreter.

What type of PR is it?

Bug Fix

Todos

  • [x] - Modified HttpBasedClient.java file

What is the Jira issue?

  • https://issues.apache.org/jira/projects/ZEPPELIN/issues/ZEPPELIN-6131

How should this be tested?

  • Zeppelin project build and run
./mvnw clean package -DskipTests
  • Add a test index and test data to Elasticsearch
# Create an index
curl -X PUT "http://localhost:9200/customer?pretty"

# Create a document
curl -X \
PUT "localhost:9200/customer/_doc/1" \
-H 'Content-Type: application/json' \
-d'
{
  "field_1": "value_1"
}'
  • Modify the Elasticsearch interpreter type and port elasticsearch.client.type: transport -> http elasticsearch.port: 9300 -> 9200

  • Previous configuration image

  • New configuration image

  • Create a Zeppelin notebook and execute a paragraph

%elasticsearch
get /customer/_doc/1
  • Result before modification - Error occurred image
org.apache.zeppelin.interpreter.InterpreterException: java.lang.NumberFormatException: For input string: "9200.0"
	at org.apache.zeppelin.interpreter.LazyOpenInterpreter.open(LazyOpenInterpreter.java:77)
	at org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer$InterpretJob.jobRun(RemoteInterpreterServer.java:808)
	at org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer$InterpretJob.jobRun(RemoteInterpreterServer.java:716)
	at org.apache.zeppelin.scheduler.Job.run(Job.java:187)
	at org.apache.zeppelin.scheduler.AbstractScheduler.runJob(AbstractScheduler.java:136)
	at org.apache.zeppelin.scheduler.FIFOScheduler.lambda$runJobInScheduler$0(FIFOScheduler.java:42)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.NumberFormatException: For input string: "9200.0"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Integer.parseInt(Integer.java:652)
	at java.base/java.lang.Integer.parseInt(Integer.java:770)
	at org.apache.zeppelin.elasticsearch.client.HttpBasedClient.<init>(HttpBasedClient.java:67)
	at org.apache.zeppelin.elasticsearch.ElasticsearchInterpreter.open(ElasticsearchInterpreter.java:136)
	at org.apache.zeppelin.interpreter.LazyOpenInterpreter.open(LazyOpenInterpreter.java:71)
	... 8 more
  • Result after modification image

Screenshots (if appropriate)

  • Refer to the above content

Questions:

  • Does the license files need to update? No.
  • Is there breaking changes for older versions? No.
  • Does this needs documentation? No.

ParkGyeongTae avatar Oct 18 '24 07:10 ParkGyeongTae

Do you know where the .0 comes from? We should rather switch off this behavior than fix the error later.

Reamer avatar Oct 18 '24 10:10 Reamer

I like this approach. Can you write a unit test that tests the behavior with different combinations?

Reamer avatar Oct 31 '24 07:10 Reamer

@Reamer Thank you for your guidance. When modifying interpreters in the Zeppelin Web UI, I discovered that integers were being saved as floats in the interpreter.json file. To fix this, I modified it to convert floats to integers before saving, where possible. Additionally, I added test code.

ParkGyeongTae avatar Nov 02 '24 03:11 ParkGyeongTae

@Reamer I have updated the PR title to "Update Interpreter to Store Values as Integers When Applicable."

ParkGyeongTae avatar Nov 12 '24 07:11 ParkGyeongTae

Merged into master/branch-0.12

Reamer avatar Nov 12 '24 10:11 Reamer