You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Stephen Mallette (Jira)" <ji...@apache.org> on 2020/06/12 16:33:00 UTC

[jira] [Commented] (TINKERPOP-2375) Text Predicates fail if they encounter non strings

    [ https://issues.apache.org/jira/browse/TINKERPOP-2375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17134360#comment-17134360 ] 

Stephen Mallette commented on TINKERPOP-2375:
---------------------------------------------

I tend to be in the camp of not throwing an exception here and not being too prescriptive about the potential anti-pattern in modelling of overloading a key with different types. That seems like something more for the underlying graph to deal with than Gremlin. Since {{P}} is a filter, I tend to think that if the type doesn't fit the filter it should just be ignored and filtered out. Of course, the way we've modeled {{P}} and its extension with {{TextP}} doesn't provide a nice clear way to solve this.

> Text Predicates fail if they encounter non strings
> --------------------------------------------------
>
>                 Key: TINKERPOP-2375
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2375
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: process
>    Affects Versions: 3.4.6
>         Environment: MacOS + TinkerPop 3.4.6 , Gremlin Console, TinkerGraph
>            Reporter: Kelvin R. Lawrence
>            Priority: Minor
>
> This issue comes from investigating the report on Stack Overflow here: [https://stackoverflow.com/questions/62013568/how-to-do-gremlin-contain-search-for-both-number-and-string]
> It was reported against Neptune but I see the same behavior with TinkerGraph. As best I can tell the poster has overloaded a property key so that it is sometimes a float and sometimes a string. There is no error if the number matches exactly but if it does not and the TextP part of the {{or}} step triggers then an exception is thrown as {{TextP.containing}} tries to work against a float value. I guess the question is, should the text predicates be smart enough to ignore non String property values? 
> Here is a simple reproducer
>  {{}}
> {code:java}
> gremlin> graph = TinkerGraph.open()
>  ==>tinkergraph[vertices:0 edges:0]
>  gremlin> g = graph.traversal()
>  ==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
>  gremlin> g.addV('test').property('x',12.5)
>  ==>v[0]
>  gremlin> g.addV('test').property('x','ABCDEF')
>  ==>v[2]
>  gremlin> g.V().hasLabel('test').or(has('x',12.3),has('x',TextP.containing('CDE')))
>  java.math.BigDecimal cannot be cast to java.lang.String
>  Type ':help' or ':h' for help.
>  Display stack trace? [yN] {code}
> {{}}
>   
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)