cypher cast string to integer in Agensgraph - cypher

I use the following query, this returns string values:
MATCH (n:artefact) RETURN (n.id)
I'm trying to cast the string to an integer, so I use the following:
MATCH (n:artefact) RETURN toInteger(n.id)
This returns the error:
[FAIL] BadSqlGrammarException->StatementCallback; bad SQL grammar [MATCH (n:artefact) RETURN toInteger(n.id);]; nested exception is org.postgresql.util.PSQLException: ERROR: function tointeger(jsonb) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
I've also tried toInt()
I'm guessing the function tointeger(jsonb) does not exist is the issue, is it trying to convert the entire jsonb in an integer rather than just the n.id?
How do I resolve this?
I'm using Agensgraph, when I start agens browser it states check version of AgensGraph ... v1.2 or under

Related

How can I perform a regex/text search on a SUPER type?

What I'm doing now:
I have a table with one field that is a json value that is stored as a super type in my staging schema.
the field containing the json is called elements
In my clean table, I typecast this field to VARCHAR in order to search it and use string functions
I want to search for the string net within that json in order to determine the key/value that I want to use for my filter
I tried the following:
select
elements
, elements_raw
from clean.events
where 1=1
and lower(elements) like '%net%'
or strpos(elements,'net')
My output
When running the above query, I keep getting an empty set returned.
My issue
I tried running the above code and using the elements_raw value instead but I got an issue :ERROR: function strpos(super, "unknown") does not exist Hint: No function matches the given name and argument types. You may need to add explicit type casts.
I checked the redshift super page and it doesn't list any specifics on searching strings within super types
Desired result:
Perform string operations on super field
Cast super field to a string type
There are some super related idiosyncrasies that are being run into here:
You cannot change the type of a super field via :: or cast()
String functions like and strpos do not work on super types
To address both of these issues, you can use the function json_serialize to return your super as a string.

In Hive, what does the 'positive' function do?

I'm working on an item-based recommender using data stored in Hive tables and stumbled across a similar scenario in Sagar Prasad's blog. I notice that he uses the POSITIVE function on the hashes of the user/product.
I'm a bit confused as to why this function exists. The documentation states that this function takes an int or double and returns that value:
"positive(INT/DOUBLE a) returns a"
For example:
hive> select positive(-1);
-1
Does that mean that the function doesn't do anything? Or am I missing some subtle nuance?
Under the hood this function is GenericUDFOPPositive.java which extends GenericUDFBaseUnary.java. positive can also be called simply as +.
For numeric types, this function does indeed do effectively nothing. For text types, it appears to attempt to do a conversion to double, since GenericUDFBaseUnary.java contains the following:
private PrimitiveTypeInfo deriveResultTypeInfo(PrimitiveTypeInfo typeInfo) {
switch(typeInfo.getPrimitiveCategory()) {
case STRING:
case VARCHAR:
case CHAR:
return TypeInfoFactory.doubleTypeInfo;
default:
return typeInfo;
}
}
However this doesn't seem to actually work, as calling positive on a string simply returns the string. This implies that at the least, the type signature of this function in the documentation is wrong, as it accepts more than just double and int.
Don't worry about being confused, having read the source code to try and work out what this function is for, I'm also now confused about why it exists!
https://github.com/apache/hive/blob/release-0.14.0/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPPositive.java
https://github.com/apache/hive/blob/release-0.14.0/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFBaseUnary.java

What is wrong with this ST_CONTAINS statement PostGIS - Find point in polygon

I'm trying the following:
Event.where('ST_Contains(?,ST_SetSRID(location, 4326)::geography)', search_polygon::geography)
add getting the error
*** NoMethodError Exception: undefined method `geography' for
but without that (::geography) I get a message telling me to cast, what do I do?
HINT: No function matches the given name and argument types. You
might need to add explicit type casts.
It looks like you are trying to use ST_Contains on geography types, but that function only works on geometry types.
If you are OK with the intersects spatial relation (see DE-9IM), then use ST_Intersects(geography, geography).

Oracle DEFAULT clause for create table. "Literal argument"?

I was just reading the documentation for the CREATE TABLE statement and it says this in relation to the DEFAULT clause:
"The DEFAULT expression can include any SQL function as long as the
function does not return a literal argument, a column reference, or a
nested function invocation."
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_7002.htm
What does it mean by the function cannot return a "literal argument". I thought returning literals was OK for DEFAULT?
Yes, it is OK to use literals with DEFAULT, for example DEFAULT 'YES' . What is telling you that text is that if you are using a function in DEFAULT, for example DEFAULT POWER(2,3) , that function POWER must not return a literal argument. You can use SQL built in functions in the clause DEFAULT , but not USER defined PLSQL functions

can't use pgxml_xpath

I'm using PostgreSQL 9.1, I thought it was supposed to support this XML integration but I can't get it to work. I try this query:
select data from ddm_table_data order by pgxml_xpath(data, '//xmltest/col1/text()', '', '');
And it comes up with the following errors:
ERROR: function pgxml_xpath(xml, unknown, unknown, unknown) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Am I missing something?
Am I missing something?
Like the error says - there's no such function. There's one called "xpath" though.
The manuals are your friend.