Access array element use JSqlParser - jsqlparser

I insert this sql into JSqlParser:
select count(distinct case when split(vir_name,"\\/")[OFFSET(0)] in ("G-Ware","RiskWare","Tool","PornWare","Trojan") then apk_name else null end) as black_apk_n from table1
and get error:
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "(" "("
at line 1, column 13.
It may has something to do with array access issue, how to manage the same thing in JSqlParser?

Unfortunately JSqlParser does not yet support these Array constructs. In fact it supports for historical reasons SQLServers and MSAccess bracket quotation like [COLUMN] instead of "COLUMN".
Here is a discussion about this: https://github.com/JSQLParser/JSqlParser/issues/677.

Related

Try to use query to vlookup and filter a set of raw data

I try to run this query:
=Query({'raw_13-19'!A:G},"Select * where C ={'Keyword'!G2:G19}", 1)
But it keeps returning:
Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered " <ID> "C "" at line 1, column 16. Was expecting one of: "(" ... "(" ...
I'm not quite sure why is this happening. Can anyone help?
Since the range is within {}, you need to use the other select notation 'Col1,Col2,Col3' instead of 'A,B,C'.
Also {'Keyword'!G2:G19} won't work, but you should use textjoin() instead.
Try:
=Query({'raw_13-19'!A:G},"Select * where Col3 matches '"&textjoin("|",1,Keyword!G2:G19)&"' ", 0)
If you have a header column on raw_13-19, then change , 0 at the end to , 1.
NOTE: the above will work with text fields, but if you have any issues, please share a mockup sheet so we can see the actual data scenario.

QUERY - Google Sheets - filter with conditions

I'm trying to filter some rows of this sheet
Google sheet sample image
I'm using the following query:
=query(Jira_query!$A:$I;"SELECT A WHERE E contains '&SDP&' AND C IN ('To Do','In Progress')")
But I'm only getting this error:
Error
PARSE_ERROR: Encountered " "C "" at line 1, column 39. Was expecting one of: "(" ... "(" ...
I would appreciate some help here, thanks!
Get rid of the ampersands before and after SDP. That is a string literal and should just be sitting between the single quotes.
In addition, I don't think QUERY supports IN; instead, use MATCHES with a pipe-separated list.
Finally, you only need to reference A:E in the QUERY, since you don't reference any columns beyond E in the SELECT clause.
So try this:
=QUERY(Jira_query!$A:$E;"SELECT A WHERE E CONTAINS 'SDP' AND C MATCHES 'To Do|In Progress'")

How to encode # in Azure Logic Apps OData Orderby Query?

I have an Excel Online (Business) spreadsheet with a 'Box #' column. I am using the Excel "List rows present in a table" connector and I would like to order by the "Box #" column.
However, when I try to enter it, I either get a syntax error or a column not found error.
"Box #": Syntax error '#' not allowed at this position.
"Box_x0020_#": Syntax error '#' not allowed at this position.
"Box_x0020__x0025_": Column not found.
"Box x0025": "Syntax error at position 11 in 'Box x0023"
Does anyone know how to properly encode the '#' character for use in an OrderBy clause of a SharePoint Logic App Connector? Or better yet, the missing online reference.
try x0023 instead of x0025
x0025 is % according to
https://abstractspaces.wordpress.com/2008/05/07/sharepoint-column-names-internal-name-mappings-for-non-alphabet/

How to use START with Cypher / Neo4j 2.0

I am trying example provided in Graph Databases book (PDF page 51-52)with Neo4j 2.0.1 (latest). It appears that I cannot just copy paste the code sample from the book (I guess the syntax is no longer valid).
START bob=node:user(username='Bob'),
charlie=node:user(username='Charlie')
MATCH (bob)-[e:EMAILED]->(charlie)
RETURN e
Got #=> Index `user` does not exist.
So, I tried without 'user'
START bob=node(username='Bob'),
charlie=node(username='Charlie')
MATCH (bob)-[e:EMAILED]->(charlie)
RETURN e
Got #=> Invalid input 'u': expected whitespace, an unsigned integer, a parameter or '*'
Tried this but didn't work
START bob=node({username:'Bob'}),
(charlie=node({username:'Charlie'})
MATCH (bob)-[e:EMAILED]->(charlie)
RETURN e
Got #=> Invalid input ':': expected an identifier character, whitespace or '}'
I want to use START then MATCH to achieve this. Would appreciate little bit of direction to get started.
From version 2.0 syntax has changed.
http://docs.neo4j.org/chunked/stable/query-match.html
Your first query should look like this.
MATCH (bob {username:'Bob'})-[e:EMAILED]->(charlie {username:'Charlie'})
RETURN e
The query does not work out of the box because you'll need to create the user index first. This can't be done with Cypher though, see the documentation for more info. Your syntax is still valid, but Lucene indexes are considered legacy. Schema indexes replace them, but they are not fully mature yet (e.g. no wildcard searches, IN support, ...).
You'll want to use labels as well, in your case a User label. The query can be refactored to:
MATCH (b:User { username:'Bob' })-[e:EMAILED]->(c:User { username:'Charlie' })
RETURN e
For good performance, add a schema index on the username property as well:
CREATE INDEX ON :User(username)
Start is optional, as noted above. Given that it's listed under the "deprecated" section in the Cypher 2.0 refcard, I would try to avoid using it going forward just for safety purposes.
However, the refcard does state that you can prepend your Cypher query with "CYPHER 1.9" (without the quotes) in order to make explicit use of the older syntax.

In Neo4j 2.0, can numbers be labels?

I read in the documentation that labels can be string or numbers. However, using only numbers gives an error:
start u=node(5) set u:1234 return labels(u);
The error is:
Invalid input '1': expected whitespace or an identifier (line 1, column 23)
Any non-empty unicode string can be used as a label name. In Cypher, you may need to use the backtick (`) syntax to avoid clashes with Cypher identifier rules.
Here is the source of that: source
I think you are running into a Cypher conflict. If you do this it should work:
start u=node(5)
set u:`1234`
return labels(u);
I was facing the same problem and finally i found the solution
use grave accent(`)
use insert your number inside it

Resources