I am trying to parse the SQL Statements with Calcite which is select * from Prutech.Member by using SQLParser.processQuery(sqlstatement) method. Calcite has a class name "Member" in the schema interface which is https://calcite.apache.org/javadocAggregate/org/apache/calcite/schema/Member.html
How to escape the Calcite class names from the given table names or column names.
Due to this I am getting the following exception.
org.apache.calcite.sql.parser.impl.ParseException: Encountered ". Member" at line 1, column 711.
Was expecting one of:
<EOF>
"AS" ...
"EXCEPT" ...
"EXTEND" ...
"FETCH" ...
"FOR" ...
"GROUP" ...
"HAVING" ...
"INTERSECT" ...
"LIMIT" ...
"MATCH_RECOGNIZE" ...
"OFFSET" ...
"ORDER" ...
"MINUS" ...
"TABLESAMPLE" ...
"UNION" ...
"WHERE" ...
"WINDOW" ...
"(" ...
<BRACKET_QUOTED_IDENTIFIER> ...
<QUOTED_IDENTIFIER> ...
<BACK_QUOTED_IDENTIFIER> ...
<IDENTIFIER> ...
<UNICODE_QUOTED_IDENTIFIER> ...
"/*+" ...
"NATURAL" ...
"JOIN" ...
"INNER" ...
"LEFT" ...
"RIGHT" ...
"FULL" ...
"CROSS" ...
"," ...
"OUTER" ...
"." <IDENTIFIER> ...
"." <QUOTED_IDENTIFIER> ...
"." <BACK_QUOTED_IDENTIFIER> ...
"." <BRACKET_QUOTED_IDENTIFIER> ...
"." <UNICODE_QUOTED_IDENTIFIER> ...
"." "*" ...
Related
In the Snowflake Documentation for "Querying Data in Staged Files" why is the syntax for the "Pattern" & "Format" parameters "=>" instead of "=" whereas for the COPY INTO syntax the "Pattern" & "Format" parameters have "="?
The documentation doesn't mention anything about this difference so I'm confused.
">=" means Greater than or Equal to
"<=" means Less than or Equal to
So, what the hell does "=>" mean?
Link to the documentation for "Querying Data in Staged Files": https://docs.snowflake.com/en/user-guide/querying-stage.html
Link to the documentation for "COPY INTO ": https://docs.snowflake.com/en/sql-reference/sql/copy-into-table.html
Link to the documentation for Snowflake Query Operators: https://docs.snowflake.com/en/sql-reference/operators.html
In general when you define function or stored procedure it will have a specific signature. This signature has to be matched during the routine call.
Example:
CREATE OR REPLACE FUNCTION test(a INT, b TEXT)
RETURNS TEXT
AS
$$
CONCAT(a, ' ', b)
$$;
SHOW FUNCTIONS LIKE 'TEST';
-- TEST(NUMBER, VARCHAR) RETURN VARCHAR
When calling test function argument order has to match its signature("positional notation"):
SELECT test(1, 'b');
-- 1 b
Unfortunately it is not possible to use named parameters for user defined objects and explicitly state the parameters("named notation"):
SELECT test(a => 1, b => 'b');
SELECT test(b => 'b', a => 1);
SELECT test(b => 'b');
Some built-ins constructs however allows to use named parameters => (for instance FLATTEN or staged file clause).
Using FLATTEN as it is easier to produce self-contained example:
FLATTEN( INPUT => <expr> [ , PATH => <constant_expr> ]
[ , OUTER => TRUE | FALSE ]
[ , RECURSIVE => TRUE | FALSE ]
[ , MODE => 'OBJECT' | 'ARRAY' | 'BOTH' ] )
All 3 invocations are correct:
-- no explicit parameters names
SELECT * FROM TABLE(FLATTEN(parse_json('{"a":1, "b":[77,88]}'), 'b')) f;
-- parameters names order: input, path
SELECT * FROM TABLE(FLATTEN(input => parse_json('{"a":1, "b":[77,88]}'), path => 'b')) f;
-- parameters names order: path, input
SELECT * FROM TABLE(FLATTEN(path => 'b', input => parse_json('{"a":1, "b":[77,88]}'))) f;
I have this code in my VIEW:
SELECT json_object_agg(code,value) FROM table1
It generates this in my postgREST api:
[{"json_object_agg":"{code1: value1, code2: value2, ...}"]
I want to remove the json_object_agg to make it like this:
[{code1: value1, code2: value2, ...}]
How do I do that?
You can't have empty result set name. I assume this is related to your previous question where you were getting
t=# select json_object_agg(code,value) from tt;
json_object_agg
----------------------------------------------------
{ "ALLOW_MAC_ADDR" : "1", "USER_ALIAS" : "James" }
So if you try to name the column with empty value (closest I can think of from your post requirements), you get the error:
t=# select json_object_agg(code,value) "" from tt;
ERROR: zero-length delimited identifier at or near """"
LINE 1: select json_object_agg(code,value) "" from tt;
^
Of course you can mokey hack it with space character, like:
t=# select json_object_agg(code,value) " " from tt;
----------------------------------------------------
{ "ALLOW_MAC_ADDR" : "1", "USER_ALIAS" : "James" }
which is ALMOST no name, but I assume you have to modify your "postgREST api" in order to do it properly - ignoring the result set attribute name
In kbase database, is there "!=" operator or some syntax can be used as "!="?
In kbase database, there is not "!=" usage, but can use "not" instead of "!=";
For example: select * from tableName where feildName1= value1 not feildName2=value2
q) Use COUNT and DISTINCT to determine how many distinct skus there are
in the skuinfo, skstinfo, and trnsact tables. Which skus are common to all tables, or unique to specific tables?
A) I was trying to find the solution to the above q in TERADATA. The first part was simple i was able to run three commands and got the distinct skus (stock keeping unit).
Now to find the common sku in all three table i am running the command but having errors :
SELECT COUNT(DISTINCT a.sku),COUNT(DISTINCT b.sku),COUNT(DISTINCT c.sku)
FROM skuinfo a INNER JOIN skstinfo b INNER JOIN trnsact c
ON a.sku=b.sku AND b.sku=c.sku;// Why is there error if i use **Where** in Place of ON?
**Error Occurred . . .**
[com.teradata.commons.datatools.sqlparsers.common.ParseException: Encountered ";" at line 3, column 31. Was expecting one of: "and" ... "at" ... "cross" ... "day" ... "full" ... "hour" ... "inner" ... "join" ... "left" ... "minute" ... "month" ... "on" ... "or" ... "right" ... "second" ... "timezone_hour" ... "timezone_minute" ... "year" ... "||" ... "(" ... "**" ... "+" ... "-" ... "*" ... "/" ... "mod" ... "." ... "[" ... ]
Please let me know why is my syntax not working, though most forums say the query is right. Thanks
I encounter an appengine error from a GQL query with "IN" operator. my query is as follows:
SELECT * FROM ratings WHERE rating >= 0.0 AND cat = 1 AND pid IN(44,14)
the error message is:
PHP Fatal error: Uncaught exception 'google\appengine\runtime\ApplicationError' with message 'Encountered "IN" at line 1, column 84.
Was expecting one of:
"contains" ...
"has" ...
"is" ...
"=" ...
"<" ...
"<=" ...
">" ...
">=" ...
"." ...
"(" ...
' in /base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php:53
I put my query in datastore admin console It works without any error and showed the exactly result.
What's wrong??
You are confused about what the IN operator does. It can not do what you want.
Please read the docs on cloud datastore https://cloud.google.com/datastore/docs/apis/gql/gql_reference
Notice that the operator = is another name for the IN and CONTAINS operators. For example, <value> = <property-name> is the same as <value> IN <property-name>, and <property-name> = <value> is the same as <property-name> CONTAINS <value>. Also <property-name> IS NULL is the same as <property-name> = NULL.