Skip to content

Missing or not-working conversion functions #571

Closed

Description

@gramian

ArcadeDB Version: v22.9.1 (build d082adc/1664822987697/main)

JDK Version: openjdk 11.0.16 2022-07-19

OS: Ubuntu 20.04

Dear Developers,

The following five issues are all related to conversion functions, either they seem to be not available, or return the wrong type? Could you please clarify?

Thank you very much

Expected behavior

  1. 0
  2. 0
  3. 2
  4. 2.0
  5. 2.00

Actual behavior

  1. Cannot execute command Unknown method name: asShort
Trace
<ArcadeDB_0> Error on command execution (PostCommandHandler)
com.arcadedb.exception.CommandExecutionException: Unknown method name: asShort
	at com.arcadedb.query.sql.method.DefaultSQLMethodFactory.createMethod(DefaultSQLMethodFactory.java:130)
	at com.arcadedb.query.sql.executor.SQLEngine.getMethod(SQLEngine.java:93)
	at com.arcadedb.query.sql.parser.MethodCall.execute(MethodCall.java:130)
	at com.arcadedb.query.sql.parser.MethodCall.execute(MethodCall.java:82)
	at com.arcadedb.query.sql.parser.Modifier.execute(Modifier.java:102)
	at com.arcadedb.query.sql.parser.BaseExpression.execute(BaseExpression.java:155)
	at com.arcadedb.query.sql.parser.Expression.execute(Expression.java:117)
	at com.arcadedb.query.sql.parser.ProjectionItem.execute(ProjectionItem.java:147)
	at com.arcadedb.query.sql.parser.Projection.calculateSingle(Projection.java:134)
	at com.arcadedb.query.sql.executor.ProjectionCalculationStep.calculateProjections(ProjectionCalculationStep.java:82)
	at com.arcadedb.query.sql.executor.ProjectionCalculationStep$1.next(ProjectionCalculationStep.java:57)
	at com.arcadedb.query.sql.executor.ScriptExecutionPlan.doExecute(ScriptExecutionPlan.java:100)
	at com.arcadedb.query.sql.executor.ScriptExecutionPlan.fetchNext(ScriptExecutionPlan.java:57)
	at com.arcadedb.query.sql.parser.LocalResultSet.fetchNext(LocalResultSet.java:46)
	at com.arcadedb.query.sql.parser.LocalResultSet.<init>(LocalResultSet.java:40)
	at com.arcadedb.database.EmbeddedDatabase.executeInternal(EmbeddedDatabase.java:1296)
	at com.arcadedb.database.EmbeddedDatabase.execute(EmbeddedDatabase.java:1244)
	at com.arcadedb.server.ServerDatabase.execute(ServerDatabase.java:415)
	at com.arcadedb.server.http.handler.PostCommandHandler.executeScript(PostCommandHandler.java:100)
	at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:71)
	at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:85)
	at com.arcadedb.server.http.handler.AbstractHandler.handleRequest(AbstractHandler.java:111)
	at io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:93)
	at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:104)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:387)
	at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:256)
	at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
	at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:59)
	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
	at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
	at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
	at org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
  1. Cannot execute command Unknown method name: asByte
Trace
<ArcadeDB_0> Error on command execution (PostCommandHandler)
com.arcadedb.exception.CommandExecutionException: Unknown method name: asByte
	at com.arcadedb.query.sql.method.DefaultSQLMethodFactory.createMethod(DefaultSQLMethodFactory.java:130)
	at com.arcadedb.query.sql.executor.SQLEngine.getMethod(SQLEngine.java:93)
	at com.arcadedb.query.sql.parser.MethodCall.execute(MethodCall.java:130)
	at com.arcadedb.query.sql.parser.MethodCall.execute(MethodCall.java:82)
	at com.arcadedb.query.sql.parser.Modifier.execute(Modifier.java:102)
	at com.arcadedb.query.sql.parser.BaseExpression.execute(BaseExpression.java:155)
	at com.arcadedb.query.sql.parser.Expression.execute(Expression.java:117)
	at com.arcadedb.query.sql.parser.ProjectionItem.execute(ProjectionItem.java:147)
	at com.arcadedb.query.sql.parser.Projection.calculateSingle(Projection.java:134)
	at com.arcadedb.query.sql.executor.ProjectionCalculationStep.calculateProjections(ProjectionCalculationStep.java:82)
	at com.arcadedb.query.sql.executor.ProjectionCalculationStep$1.next(ProjectionCalculationStep.java:57)
	at com.arcadedb.query.sql.executor.ScriptExecutionPlan.doExecute(ScriptExecutionPlan.java:100)
	at com.arcadedb.query.sql.executor.ScriptExecutionPlan.fetchNext(ScriptExecutionPlan.java:57)
	at com.arcadedb.query.sql.parser.LocalResultSet.fetchNext(LocalResultSet.java:46)
	at com.arcadedb.query.sql.parser.LocalResultSet.<init>(LocalResultSet.java:40)
	at com.arcadedb.database.EmbeddedDatabase.executeInternal(EmbeddedDatabase.java:1296)
	at com.arcadedb.database.EmbeddedDatabase.execute(EmbeddedDatabase.java:1244)
	at com.arcadedb.server.ServerDatabase.execute(ServerDatabase.java:415)
	at com.arcadedb.server.http.handler.PostCommandHandler.executeScript(PostCommandHandler.java:100)
	at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:71)
	at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:85)
	at com.arcadedb.server.http.handler.AbstractHandler.handleRequest(AbstractHandler.java:111)
	at io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:93)
	at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:104)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:387)
	at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:256)
	at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
	at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:59)
	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
	at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
	at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
	at org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
  1. Cannot execute command Unknown method name: asDouble
Trace
<ArcadeDB_0> Error on command execution (PostCommandHandler)
com.arcadedb.exception.CommandExecutionException: Unknown method name: asDouble
	at com.arcadedb.query.sql.method.DefaultSQLMethodFactory.createMethod(DefaultSQLMethodFactory.java:130)
	at com.arcadedb.query.sql.executor.SQLEngine.getMethod(SQLEngine.java:93)
	at com.arcadedb.query.sql.parser.MethodCall.execute(MethodCall.java:130)
	at com.arcadedb.query.sql.parser.MethodCall.execute(MethodCall.java:82)
	at com.arcadedb.query.sql.parser.Modifier.execute(Modifier.java:102)
	at com.arcadedb.query.sql.parser.BaseExpression.execute(BaseExpression.java:155)
	at com.arcadedb.query.sql.parser.Expression.execute(Expression.java:117)
	at com.arcadedb.query.sql.parser.ProjectionItem.execute(ProjectionItem.java:147)
	at com.arcadedb.query.sql.parser.Projection.calculateSingle(Projection.java:134)
	at com.arcadedb.query.sql.executor.ProjectionCalculationStep.calculateProjections(ProjectionCalculationStep.java:82)
	at com.arcadedb.query.sql.executor.ProjectionCalculationStep$1.next(ProjectionCalculationStep.java:57)
	at com.arcadedb.query.sql.executor.ScriptExecutionPlan.doExecute(ScriptExecutionPlan.java:100)
	at com.arcadedb.query.sql.executor.ScriptExecutionPlan.fetchNext(ScriptExecutionPlan.java:57)
	at com.arcadedb.query.sql.parser.LocalResultSet.fetchNext(LocalResultSet.java:46)
	at com.arcadedb.query.sql.parser.LocalResultSet.<init>(LocalResultSet.java:40)
	at com.arcadedb.database.EmbeddedDatabase.executeInternal(EmbeddedDatabase.java:1296)
	at com.arcadedb.database.EmbeddedDatabase.execute(EmbeddedDatabase.java:1244)
	at com.arcadedb.server.ServerDatabase.execute(ServerDatabase.java:415)
	at com.arcadedb.server.http.handler.PostCommandHandler.executeScript(PostCommandHandler.java:100)
	at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:71)
	at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:85)
	at com.arcadedb.server.http.handler.AbstractHandler.handleRequest(AbstractHandler.java:111)
	at io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:93)
	at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:104)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:387)
	at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:256)
	at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:162)
	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:100)
	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:57)
	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
	at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:291)
	at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:286)
	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
	at org.xnio.nio.QueuedNioTcpServer2.acceptTask(QueuedNioTcpServer2.java:178)
	at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:612)
	at org.xnio.nio.WorkerThread.run(WorkerThread.java:479)
  1. 2

  2. 2

Steps to reproduce

  1. SELECT $tmp.asShort() LET $tmp = 0.2;
  2. SELECT $tmp.asByte() LET $tmp = 0.2;
  3. SELECT $tmp.asDouble() LET $tmp = 2;
  4. SELECT $tmp.asFloat() LET $tmp = 2;
  5. SELECT $tmp.asDecimal() LET $tmp = 2;

Comprehension Question:

I wonder if all these types are actually needed. There are three signed integer types (short, integer, long) and two floating point types (float, double). I likely overlook a practical or historical reason for having all of these, but in my humble (naive) opinion, one integer type (long), and one floating point type (double) could be sufficient.

The reasons I could think of having all of those is memory/storage for a lot of numbers, but overflow for short and integer would be a (user) issue, for floating point, floats make also sense for saving memory/storage ie in ML/AI but then again no (popular) half-precision type is provided.

Could you explain?

Thank you

Activity

  1. self-assigned this
    on Oct 17, 2022
  2. added this to the 22.10.1 milestone on Oct 17, 2022
  3. lvca commented on Oct 17, 2022

    @lvca
    Member

    We decided to remove them from ArcadeDB during the fork from OrientDB (for simplicity and the lack of use case that are really needed), but I'm going to restore them for compatibility with OrientDB apps.

  4. gramian commented on Oct 17, 2022

    @gramian
    CollaboratorAuthor

    @lvca What about 4. and 5.?

  5. lvca commented on Oct 18, 2022

    @lvca
    Member

    How do you print that value? There could be a round of the value while printing.

  6. gramian commented on Oct 18, 2022

    @gramian
    CollaboratorAuthor

    Just using the studio tool.

  7. lvca commented on Oct 18, 2022

    @lvca
    Member

    Ok, so it's the Studio(probably the javascript layer) that hides the floating part if equals to .0. I'm going to reopen this issue to get fixed in Studio.

  8. reopened this on Oct 18, 2022
  9. lvca commented on Oct 18, 2022

    @lvca
    Member

    Just checked and the org.json.JsonObject class automatically removes .0 as a suffix. In Javascript 2.0 is equivalent to 2 so it's correct. Unfortunately, this information gets lost in Studio because of the usage of the JSON lib. The only way would be to convert the value into a string, like:

    SELECT $tmp.asDouble().asString() LET $tmp = 2;
    

    But must be specified by the user if wants it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions