I'm trying to use CHARINDEX function to find the occurrence of a char. in Databricks sql (SPARK-SQL).
But seems CHARINDEX is not recognized and throwing the below error.
ERROR:
Undefined function: 'charindex'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.
Kindly help me in this
Tried with the below example given in databricks documentation
Ex: SELECT charindex('bar', 'abcbarbar', 5)
https://docs.databricks.com/sql/language-manual/functions/charindex.html
Related
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
I created a JS UDF in Snowflake that has two inputs: a string from a column, and then another string that I use to create a mapping object.
Here's the function:
CREATE OR REPLACE FUNCTION function(supplier_name varchar, supplier_replace varchar)
RETURNS string
LANGUAGE JAVASCRIPT
AS
$$
regex_string = SUPPLIER_REPLACE.replace(/\b:\b/g, '":"').toLowerCase();
regex_final = '{"' + regex_string.replace(/\s*,\s*/g, '","') + '"}'
obj = JSON.parse(regex_final);
var supplier = SUPPLIER_NAME.toLowerCase();
for (var key in obj) {
if (supplier.includes(key)) {
var new_supplier = obj[key]
}
}
return new_supplier;
$$;
When I call the function in a SQL statement
select parent_supplier
, function(parent_supplier, 'Fedex:Fedex')
from table
I get the following error: "JavaScript execution error: Uncaught TypeError: Cannot read properties of undefined (reading 'toLowerCase') in TEST at ' const supplier = SUPPLIER_NAME.toLowerCase();' position 35 stackstrace: TEST line: 7".
I know this error is because I'm using a column as one of my input variables, but I can't figure out how to properly call it.
I'd appreciate any help!
Function works testing with a string as the input variable.
The error message claims the error is on a line reading this:
const supplier = SUPPLIER_NAME.toLowerCase();
However, there is no line like that in the UDF code in the question. Instead, the line closest to that line is this one:
var supplier = SUPPLIER_NAME.toLowerCase();
Since the line with the const does not appear in the UDF, this means it must be calling a different version of the UDF. There are a couple of common reasons why this happens. UDFs are owned by a directory and schema, and unless they're explicitly called using a three-part identifier (db_name.schema_name.udf_name), Snowflake will use the current schema in context and use that schema's UDF if there is one with that name and signature. The other reason is that Snowflake supports overloaded UDFs. That means that multiple versions of the same UDF name can exist provided they have different numbers of input parameters or different types of input parameters.
You can check to make sure the SQL is calling the right version of the UDF by placing something like return "foo" or some other recognizable return on the first line of the UDF temporarily. If calling it does not return that message (assuming there are no compilation errors) then it's running another version of the UDF.
When i try to execute this function PROD_TYPE: IIf([PROD_CAT]="OTHER";"OTHER";Mid([PROD_CAT];5)) I get compilation error message. I have tried to check if there was any missing reference i could uncheck but i found non. the MID function seems to be the problem. because when i try to create a dummy query using MID function, it threw the same error message at me.
Access control sources do not accept semicolons when providing parameters, you need to use commas as you can see below:
IIf([PROD_CAT]="Other","Other",Mid([PROD_CAT],5))
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).
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.