Repository navigation
Description
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
0022.02.00
Actual behavior
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)
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)
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)
-
2 -
2
Steps to reproduce
SELECT $tmp.asShort() LET $tmp = 0.2;SELECT $tmp.asByte() LET $tmp = 0.2;SELECT $tmp.asDouble() LET $tmp = 2;SELECT $tmp.asFloat() LET $tmp = 2;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
Implemented missing SQL methods: asDouble(), asShort() and asByte()
lvca commentedon Oct 17, 2022
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.
gramian commentedon Oct 17, 2022
@lvca What about 4. and 5.?
lvca commentedon Oct 18, 2022
How do you print that value? There could be a round of the value while printing.
gramian commentedon Oct 18, 2022
Just using the studio tool.
lvca commentedon Oct 18, 2022
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.lvca commentedon Oct 18, 2022
Just checked and the
org.json.JsonObjectclass automatically removes.0as a suffix. In Javascript2.0is equivalent to2so 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:But must be specified by the user if wants it.
chore(deps-dev): bump js-yaml from 3.14.1 to 3.14.2 in /e2e-js [skip ci]
chore(studio-deps-dev)(deps-dev): bump enhanced-resolve from 5.21.0 t…
Implemented missing SQL methods: asDouble(), asShort() and asByte()
chore(deps-dev): bump js-yaml from 3.14.1 to 3.14.2 in /e2e-js [skip ci]
chore(studio-deps-dev)(deps-dev): bump enhanced-resolve from 5.21.0 t…