orientechnologies / orientdb

OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries.
https://orientdb.dev
Apache License 2.0
4.72k stars 870 forks source link

Parser doesn't like custom functions associated with tab and parenthesis #10059

Open sylvain324 opened 5 months ago

sylvain324 commented 5 months ago

OrientDB Version: 3.0.44 and 3.2.26

Java Version: openjdk 11.0.21 2023-10-17

OS: ubuntu 22.04.03

Actual behavior

I'm using a SELECT with a custom function. If and only if in the prepareStatement contains a String argument with a TAB,and the where statement is between parenthesis, then I have the following exception.

Note: the first letter of the custom function is missing in the error messages.

With orient-db 3.0.44:

SEVERE: Exception `7A6EBE1E` in storage `memory:functionNotFound3`: 3.0.44 - Veloce (build ad8788032704c290abc8ad24e024a79672e53ebd, branch UNKNOWN)
com.orientechnologies.orient.core.exception.OQueryParsingException: Error on parsing query at position #27: Error on parsing query
Query:  (inglob(`_label`, "\tfoo") = true )
--------------------------------^
    DB name="functionNotFound3"
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.text(OSQLPredicate.java:107)
    at com.orientechnologies.orient.core.sql.filter.OSQLFilter.<init>(OSQLFilter.java:53)
    at com.orientechnologies.orient.core.sql.OSQLEngine.parseCondition(OSQLEngine.java:496)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.parse(OCommandExecutorSQLSelect.java:285)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.parse(OCommandExecutorSQLSelect.java:96)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:58)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:39)
    at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.command(OAbstractPaginatedStorage.java:4460)
    at com.orientechnologies.orient.core.command.OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:68)
    at com.tinkerpop.blueprints.impls.orient.OrientGraphCommand.execute(OrientGraphCommand.java:49)
    at synapse.carto.BugCustomFunctionWithTab.functionNotFound(BugCustomFunctionWithTab.java:51)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Caused by: com.orientechnologies.orient.core.sql.OCommandSQLParsingException: No function with name 'nglob', available names are : [math_toradians,math_subtractexact,math_asin,st_geomfromtext,math_tanh,math_cbrt,shortestpath,math_ieeeremainder,st_srid,symmetricdifference,traversedvertex,if,indexkeysize,math_tan,unionall,math_cos,in,coalesce,concat,math_cosh,gremlin,math_nextafter,percentile,math_scalb,math_fma,difference,document,math_sqrt,math_floormod,sum,st_within,out,math_abs,st_distance_sphere,math_tointexact,min,math_pow,search_more,traversededge,math_max,math_getexponent,map,math_todegrees,set,max,math_log10,math_min,search_index,abs,math_ceil,inglob,math_nextup,math_log,st_intersects,math_signum,st_dwithin,first,math_hypot,date,encode,math_multiplyhigh,search_fields,dijkstra,st_distance,traversedelement,decode,bothv,st_asbinary,uuid,math_nextdown,mode,sysdate,math_decrementexact,math_exp,search_class,math_multiplyfull,bothe,st_equals,last,math_rint,st_envelope,math_floor,count,format,math_log1p,st_contains,list,both,sequence,st_geomfromgeojson,eval,median,st_astext,decimal,astar,distance,distinct,st_disjoint,math_round,st_buffer,math_copysign,avg,math_sin,math_floordiv,math_sinh,ifnull,stddev,outv,math_multiplyexact,math_atan,ine,oute,intersect,math_incrementexact,st_asgeojson,math_random,label,math_expm1,inv,variance,math_acos,math_atan2,math_addexact,math_ulp,math_negateexact,throwcme]
    DB name="functionNotFound3"
    at com.orientechnologies.orient.core.sql.OSQLEngine.getFunction(OSQLEngine.java:456)
    at com.orientechnologies.orient.core.sql.functions.OSQLFunctionRuntime.setRoot(OSQLFunctionRuntime.java:208)
    at com.orientechnologies.orient.core.sql.filter.OSQLFilterItemAbstract.<init>(OSQLFilterItemAbstract.java:61)
    at com.orientechnologies.orient.core.sql.functions.OSQLFunctionRuntime.<init>(OSQLFunctionRuntime.java:57)
    at com.orientechnologies.orient.core.sql.OSQLHelper.getFunction(OSQLHelper.java:262)
    at com.orientechnologies.orient.core.sql.OSQLHelper.parseValue(OSQLHelper.java:240)
    at com.orientechnologies.orient.core.sql.OSQLHelper.parseValue(OSQLHelper.java:225)
    at com.orientechnologies.orient.core.sql.OSQLHelper.parseValue(OSQLHelper.java:221)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.extractConditionItem(OSQLPredicate.java:354)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.extractCondition(OSQLPredicate.java:181)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.extractConditions(OSQLPredicate.java:144)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.extractConditionItem(OSQLPredicate.java:294)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.extractCondition(OSQLPredicate.java:181)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.extractConditions(OSQLPredicate.java:144)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.text(OSQLPredicate.java:96)
    ... 79 more

With orient-db 3.2.26:

SEVERE: Exception `0447521E` in storage `memory:functionNotFound3`: 3.2.26 (build ${buildNumber}, branch UNKNOWN)
com.orientechnologies.orient.core.exception.OQueryParsingException: Error on parsing query at position #27: Error on parsing query
Query:  (inglob(`_label`, "\tfoo") = true )
--------------------------------^
    DB name="functionNotFound3"
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.text(OSQLPredicate.java:112)
    at com.orientechnologies.orient.core.sql.filter.OSQLFilter.<init>(OSQLFilter.java:53)
    at com.orientechnologies.orient.core.sql.OSQLEngine.parseCondition(OSQLEngine.java:528)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.parse(OCommandExecutorSQLSelect.java:327)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.parse(OCommandExecutorSQLSelect.java:126)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:58)
    at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:38)
    at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.command(OAbstractPaginatedStorage.java:4167)
    at com.orientechnologies.orient.core.command.OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:63)
    at com.tinkerpop.blueprints.impls.orient.OrientGraphCommand.execute(OrientGraphCommand.java:48)
    at synapse.carto.BugCustomFunctionWithTab.functionNotFound(BugCustomFunctionWithTab.java:51)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Caused by: com.orientechnologies.orient.core.sql.OCommandSQLParsingException: No function with name 'nglob', available names are : [math_toradians,math_subtractexact,math_asin,st_geomfromtext,math_tanh,math_cbrt,shortestpath,math_ieeeremainder,st_srid,symmetricdifference,traversedvertex,if,indexkeysize,math_tan,unionall,math_cos,in,coalesce,concat,math_cosh,gremlin,math_nextafter,percentile,strcmpci,math_scalb,math_fma,difference,interval,document,math_sqrt,math_floormod,sum,st_within,out,math_abs,st_distance_sphere,math_tointexact,min,math_pow,search_more,traversededge,math_max,math_getexponent,map,math_todegrees,set,max,math_log10,math_min,search_index,abs,math_ceil,inglob,math_nextup,math_log,st_intersects,math_signum,st_dwithin,first,math_hypot,date,encode,math_multiplyhigh,search_fields,dijkstra,st_distance,traversedelement,decode,bothv,st_asbinary,uuid,math_nextdown,mode,sysdate,math_decrementexact,math_exp,search_class,math_multiplyfull,bothe,st_equals,last,math_rint,st_envelope,math_floor,count,format,math_log1p,st_contains,list,both,sequence,st_geomfromgeojson,eval,median,st_astext,decimal,astar,distance,distinct,st_disjoint,math_round,st_buffer,math_copysign,avg,math_sin,math_floordiv,math_sinh,ifnull,stddev,outv,math_multiplyexact,math_atan,ine,oute,intersect,math_incrementexact,st_asgeojson,math_random,label,math_expm1,inv,variance,math_acos,math_atan2,math_addexact,math_ulp,math_negateexact,throwcme]
    DB name="functionNotFound3"
    at com.orientechnologies.orient.core.sql.OSQLEngine.getFunction(OSQLEngine.java:485)
    at com.orientechnologies.orient.core.sql.functions.OSQLFunctionRuntime.setRoot(OSQLFunctionRuntime.java:231)
    at com.orientechnologies.orient.core.sql.filter.OSQLFilterItemAbstract.<init>(OSQLFilterItemAbstract.java:69)
    at com.orientechnologies.orient.core.sql.functions.OSQLFunctionRuntime.<init>(OSQLFunctionRuntime.java:55)
    at com.orientechnologies.orient.core.sql.OSQLHelper.getFunction(OSQLHelper.java:266)
    at com.orientechnologies.orient.core.sql.OSQLHelper.parseValue(OSQLHelper.java:244)
    at com.orientechnologies.orient.core.sql.OSQLHelper.parseValue(OSQLHelper.java:228)
    at com.orientechnologies.orient.core.sql.OSQLHelper.parseValue(OSQLHelper.java:223)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.extractConditionItem(OSQLPredicate.java:367)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.extractCondition(OSQLPredicate.java:188)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.extractConditions(OSQLPredicate.java:151)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.extractConditionItem(OSQLPredicate.java:306)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.extractCondition(OSQLPredicate.java:188)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.extractConditions(OSQLPredicate.java:151)
    at com.orientechnologies.orient.core.sql.filter.OSQLPredicate.text(OSQLPredicate.java:97)
    ... 79 more

Steps to reproduce

package synapse.carto;

import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.command.OCommandRequest;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.sql.OCommandSQL;
import com.orientechnologies.orient.core.sql.OSQLEngine;
import com.orientechnologies.orient.core.sql.functions.OSQLFunctionAbstract;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;
import org.junit.jupiter.api.Test;

public class BugCustomFunctionWithTab {

    class InGlobOdbFct extends OSQLFunctionAbstract {
        public InGlobOdbFct() {
            super("inglob", 0, 50);
        }
        @Override
        public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParams, OCommandContext iContext) {
            return true;
        }
        @Override
        public String getSyntax() {
            return "inglob(<field>, <glob_1>, ..., <glob_n>)";
        }
    }

    @Test
    public void functionNotFound() {
        OSQLEngine engine = OSQLEngine.getInstance();
        engine.registerFunction("inglob", new InGlobOdbFct());
        OrientGraph graph = new OrientGraphFactory("memory:BugCustomFunctionWithTab/functionNotFound3", "admin", "admin").getTx();

        String predicate = "inglob(`_label`, ?) = ?";

        OCommandRequest req = graph.command(new OCommandSQL("SELECT `_label` FROM `E` WHERE "+predicate));
        req.execute("foo", true);

        req = graph.command(new OCommandSQL("SELECT `_label` FROM `E` WHERE "+predicate));
        req.execute("\tfoo", true);

        predicate = "(inglob(`_label`, ?) = ?)";

        req = graph.command(new OCommandSQL("SELECT `_label` FROM `E` WHERE "+predicate));
        req.execute("foo", true);

        req = graph.command(new OCommandSQL("SELECT `_label` FROM `E` WHERE "+predicate));
        // OCommandSQLParsingException: No function with name 'nglob', available names are : [math_toradians,...,inglob,...,throwcme]
        req.execute("\tfoo", true);
    }
}
andrii0lomakin commented 5 months ago

Hi @tglman, I thought OCommands use old deprecated parsers, don't they?

tglman commented 5 months ago

Hi,

Yes OCommandSQL is deprecate and also the API com.tinkerpop.blueprints.impls.orient.OrientGraph is deprecated that is part of TP-2 now there is TP-3==gremlin from here ( https://central.sonatype.com/artifact/com.orientechnologies/orientdb-gremlin ) that has a commadSql method also if is need to use just SQL without gremlin, OrientDB support all the graph query anyway