Skip to content

Missing or not-working conversion functions #571

@gramian

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions