Azure Search throwing an error when an apostrophe is included - azure-cognitive-search

When performing an Azure search which includes an apostrophe - in this case, l'expedition - Azure throws an error,
"Invalid expression: ')' or ',' expected at position 53 in '((search.ismatchscoring('navigation_title_s:(/.*\\\"l\\'expedition\\\".*/)',null, 'full', null))))'.\r\nParameter name: $filter"
This is the search that is being generated:
$filter=((search.ismatchscoring('navigation_title_s:(/.*\"l\'expedition\".*/)',null, 'full', null)))
Thanks for the help!

You can escape single quotes in OData by doubling them. In your case:
$filter=((search.ismatchscoring('navigation_title_s:(/.*\"l''expedition\".*/)',null, 'full', null)))
would work.

Related

Snowflake JSON with foreign language to tabular format dynamically

I read through snowflake documentation and the web and found only one solution to my problem by https://stackoverflow.com/users/12756381/greg-pavlik which can be found here Snowflake JSON to tabular
This doesn't work on data with Russian attribute names and attribute values. What modifications can be made for this to fit my case?
Here is an example:
create or replace table target_json_table(
v variant
);
INSERT INTO target_json_table SELECT parse_json('{
"at": {
"cf": "NV"
},
"pd": {
"мо": "мо",
"ä": "ä",
"retailerName": "retailer",
"productName":"product"
}
}');
call create_view_over_json('target_json_table', 'V', 'MY_VIEW');
ERROR: Encountered an error while creating the view. SQL compilation error: syntax error line 7 at position 7 unexpected 'ä:'. syntax error line 8 at position 7 unexpected 'мо'.
There was a bug in the original SQL used as a basis for the creation of the stored procedure. I have corrected that. You can get an update on the Github page. The changed section is here:
sql =
`
SELECT DISTINCT '"' || array_to_string(split(f.path, '.'), '"."') || '"' AS path_nAme, -- This generates paths with levels enclosed by double quotes (ex: "path"."to"."element"). It also strips any bracket-enclosed array element references (like "[0]")
DECODE (substr(typeof(f.value),1,1),'A','ARRAY','B','BOOLEAN','I','FLOAT','D','FLOAT','STRING') AS attribute_type, -- This generates column datatypes of ARRAY, BOOLEAN, FLOAT, and STRING only
'"' || array_to_string(split(f.path, '.'), '.') || '"' AS alias_name -- This generates column aliases based on the path
FROM
#~TABLE_NAME~#,
LATERAL FLATTEN(#~COL_NAME~#, RECURSIVE=>true) f
WHERE TYPEOF(f.value) != 'OBJECT'
AND NOT contains(f.path, '[') -- This prevents traversal down into arrays
limit ${ROW_SAMPLE_SIZE}
`;
Previously this SQL simply replaced non-ASCII characters with underscores. The updated SQL will wrap key names in double quotes to create non-ASCII key names.
Be sure that's what you want it to do. Also, the keys are nested. I decided that the best way to handle that is to create column names in the view with dot notation, for example one column name is pd.ä. That will require wrapping the column name with double quotes, such as:
select * from MY_VIEW where "pd.ä" = 'ä';
Final note: The name of your stored procedure is create_view_over_json, however, in the Github project the name is create_view_over_variant. When you update, be sure to call the right procedure.

snowflake regex_replace not working as expected

I am trying to do this that strips "['" or "']" in the string.
For Example, if we have ['Customer Name'] it should be "Customer Name"
select regexp_replace("['Customers NY']","\\['|\\']","") as customername;
I am getting this error--
SQL compilation error: error line 1 at position 22 invalid identifier "['Customers NY']"
It's a typo..
ALL string in SQL are single quotes only.. you double quotes are for named objects like columns/tables.
Then you will have to escape the quotes in the quotes
select regexp_replace('[\'Customers NY\']','\\[\'|\'\\]','') as customername;
gives:
CUSTOMERNAME
Customers NY
Double $$ makes escaping easier. Combine that with translate and you could do
select translate('[\'Customers NY\']',$$[']$$,'');

Syntax Error in Azure Data Factory SOQL Query WHERE LastModifiedDate >= datetime

I'm working in Azure Data Factory V2, attempting to query from a Salesforce object where the LastModifiedDate in the object is greater than or equal to a recent date. I've been receiving syntax errors on extremely simple SOQL queries, queries that work just fine in Salesforce Workbench. Below, I've listed examples of queries I've run in the ADF Copy Data activity, along with the errors I received when debugging the pipeline.
Query 1
Select Id from "Object" WHERE LastModifiedDate >=
#{formatDateTime(activity('Yesterday').output.firstRow.Yesterday,'yyyy-MM-ddTHH:mm:ssZ')}
Result 1
{
"errorCode": "2200",
"message": "Failure happened on 'Source' side. ErrorCode=UserErrorOdbcOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=ERROR [HY000] [Microsoft][Salesforce] (120) SOQL_FIRST mode prepare failure:\nSOQL error: [Microsoft][Salesforce] (30) Syntax error or access violation when parsing SOQL.\nSQL error: [Microsoft][SQLEngine] (31480) syntax error near 'Select Id from \"Object\" WHERE LastModifiedDate >= 2018-08-13T16<<< ??? >>>:05:06Z'.,Source=Microsoft.DataTransfer.ClientLibrary.Odbc.OdbcConnector,''Type=System.Data.Odbc.OdbcException,Message=ERROR [HY000] [Microsoft][Salesforce] (120) SOQL_FIRST mode prepare failure:\nSOQL error: [Microsoft][Salesforce] (30) Syntax error or access violation when parsing SOQL.\nSQL error: [Microsoft][SQLEngine] (31480) syntax error near 'Select Id from \"Object\" WHERE LastModifiedDate >= 2018-08-13T16<<< ??? >>>:05:06Z'.,Source=Microsoft Salesforce ODBC Driver,'",
"failureType": "UserError",
"target": "Event Fix Pipeline"
}
Query 2
SELECT Id FROM "Object" WHERE LastModifiedDate >= 2018-08-14T00:00:00Z
Result 2
{
"errorCode": "2200",
"message": "Failure happened on 'Source' side. ErrorCode=UserErrorOdbcOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=ERROR [HY000] [Microsoft][Salesforce] (120) SOQL_FIRST mode prepare failure:\nSOQL error: [Microsoft][Salesforce] (30) Syntax error or access violation when parsing SOQL.\nSQL error: [Microsoft][SQLEngine] (31480) syntax error near 'SELECT Id FROM \"Object\" WHERE LastModifiedDate >= 2018-08-14T00<<< ??? >>>:00:00Z'.,Source=Microsoft.DataTransfer.ClientLibrary.Odbc.OdbcConnector,''Type=System.Data.Odbc.OdbcException,Message=ERROR [HY000] [Microsoft][Salesforce] (120) SOQL_FIRST mode prepare failure:\nSOQL error: [Microsoft][Salesforce] (30) Syntax error or access violation when parsing SOQL.\nSQL error: [Microsoft][SQLEngine] (31480) syntax error near 'SELECT Id FROM \"Object\" WHERE LastModifiedDate >= 2018-08-14T00<<< ??? >>>:00:00Z'.,Source=Microsoft Salesforce ODBC Driver,'",
"failureType": "UserError",
"target": "Event Fix Pipeline"
}
What could be causing this syntax error?
Removing the quotation marks around Object seems to solve your problem.
SELECT Id FROM Object WHERE LastModifiedDate >= 2018-08-14T00:00:00Z.
I tested the query with quotation marks in Salesforce Developer Console and got "Unknown error parsing query", so I believe it's an invalid SOQL query with the quotation marks.
Lol, In my case it was a semicolon at the end of the SOQL statement.

How to replace escape character in Netezza column

I am trying to replace escape character in Netezza column, but it is not properly replacing.
Please help me some one on this.
select replace('replaces\tring','\','\\\\');
I need output as replaces\\\\tring. Below is the error message i am getting...
ERROR [42S02] ERROR: Function 'REPLACE(UNKNOWN, UNKNOWN, UNKNOWN)'
does not exist Unable to identify a function that satisfies the given
argument types You may need to add explicit typecasts
Thanks in advance.
This is because REPLACE function needs to be installed (which is not by default). There is another function which is called TRANSLATE which can be used in a limited way instead of REPLACE but unfortunately won't fit in your situation.
You can use the below query instead:
SELECT SUBSTRING(x, 1, INSTR(x, '\') - 1) || '\\\\' || SUBSTRING(x, INSTR(x, '\') + LENGTH('\')) FROM
(SELECT 'replaces\tring' AS x) t
\ passed to INSTR and LENGTH is the string to be replaced. Note that they occur in three positions.
\\\\ in the middle is the replacement string.
replaces\tring is the string to search in.
Check the below example for replace love with like in I love Netezza:
SELECT SUBSTRING(x, 1, INSTR(x, 'love') - 1) || 'like' || SUBSTRING(x, INSTR(x, 'love') + LENGTH('love')) FROM
(SELECT 'I love Netezza' AS x) t
That particular function is part of the "SQL Extensions toolkit" and on our system it is placed in the ADMIN schema of the SQLEXT database. All users have been granted execute access to that schema. Furthermore the database.schema have been placed in the path (the DBA's did it globally, but you can issue a "set PATH=..." in your session if need be)
our path is:
select current_path;
CURRENT_PATH
---------------------------------------------------------------------------------------
SQLEXT.ADMIN,INZA.INZA,NZA.INZA,NZM.INZA,NZMSG.INZA,NZR.INZA,NZRC.INZA,SYNCHDB.ADMIN
and as you can see the SQLEXT is at the beginning...

!= OR <> OR NOT IN Operators Supports in ODATA?

i have the query for external object named as test__x.
I am writing the query to get the data using OData 4.0 in external data sourse by applying the NOT EQUAL TO logic with != OR <> OR NOT IN operators then facing an error stating as below.
SQL:
select id,status__c from current_year_order_summary__x where status__c NOT IN('C') LIMIT 2000
Error:
"Error received from the external system: 500:
com.informatica.cloud.api.adapter.runtime.exception.ReadException:
java.sql.SQLException: [Teradata Database] [TeraJDBC 15.10.00.14]
[Error 3707] [SQLState 42000] Syntax error, expected something like a
'SUCCEEDS' keyword or a 'MEETS' keyword or a
'PRECEDES' keyword or an 'IN' keyword or a
'CONTAINS' keyword between the word 'status__c ' and
'|'."
In OData 4, the equality and inequality operators are eq and ne.

Resources