ZCQL V2 Syntax and Exceptions
Catalyst has added several syntax upgrades and enhancements to help you write ZCQL queries more effectively. These new syntax upgrades will provide additional functionalities and enable you to perform data related operations in the Data Store with much ease.
-
To use these feature enhancements, you will need to migrate to the V2 version. The syntax upgrades will not be applicable if you implement them while executing ZCQL commands in V1.
-
From December 01st, 2024, all your current projects in all your Orgs present in the Development Environment will be automatically mapped to ZCQL V2 Parser.
-
From April 01st, 2025, all the projects present in all Orgs that have already been mapped to ZCQL V2 Parser in Development Environment will be automatically mapped to ZCQL V2 Parser in the Production Environment, if and when production is enabled for the project.
The following exception and syntax nuances need to be kept in mind when you execute a ZCQL query:
-
The AVG () ZCQL function can be applied on the following data types:
- Date
- DateTime
- Boolean
-
When you are indicating a value in your ZCQL statement, indicate the value in single quotes.
For example, if you have to fetch a particular name from an employee database, you will write the command in the following manner:copySELECT Name FROM Employee_DB WHERE name = 'Amelia'
-
If a column is of Boolean data type:
- No string values are permitted.
- Boolean data type will only support the following values:
- FALSE
- TRUE
- NULL
-
If you are using an Encrypted datatype, then the following ZCQL functions cannot be used on that column:
- AVG()
- SUM()
- MAX()
- MIN()
-
Appropriate exceptions have been added when you use comparative operators like Less Than, Greater Than, Less Than or Equal, and Greater Than or Equal, on Encrypted Text, and Boolean data type. These exceptions are not applicable for Equal and Not Equal operators.
-
Subqueries are now supported in WHERE clause statements. You can find out more about them from this help document.
-
ORDER BY clause now supports the use of ZCQL functions.
-
In all columns where you use the ORDER BY clause, the ASC and DESC functionality can now be applied. You can also apply ASC and DESC for individual columns.
Example Database:
Consider the following database - ZylkerEmployeeCompensation
Name | Salary | Reimbursement |
---|---|---|
Michelle Mascarenhas | 90000 | 10000 |
Bruce Kyle | 3000000 | 45000 |
Clark Kane | 3300 | 1500 |
Judith Bridges | 4700 | 300 |
Devon Dreymond | 80000 | 2300 |
Ashley Kim | 6000 | 200 |
Execute the following command to list the table
copySELECT Salary, Reimbursement FROM ZylkerEmployeeCompensation ORDER BY Salary ASC, Reimbursement DESC
Output:
ZylkerEmployeeCompensation.Salary | ZylkerEmployeeCompensation.Reimbursement |
---|---|
3300 | 45000 |
4700 | 10000 |
6000 | 2300 |
80000 | 1500 |
90000 | 300 |
3000000 | 200 |
-
Appropriate exceptions will be triggered in the following cases:
- If the permitted max/min value has been exceeded in Integer datatype.
- If the character length is longer than the value set by you in VarChar datatype.
- If the value is beyond the supported range in BIGINT datatype.
-
You can write four JOIN clauses in a single ZCQL statement. However, you can only write one JOIN condition for each join clause.
-
Table Alias functionality is now supported in ZCQL. You can now invoke alias functionality in ZCQL using the AS ZCQL command. Using this command you can refer to your table with other names.
Example Database:
Consider the following databases:
Table 1: ZylkerEmployeeCompensation
Name | Salary | Reimbursement |
---|---|---|
Michelle Mascarenhas | 90000 | 10000 |
Bruce Kyle | 3000000 | 45000 |
Clark Kane | 3300 | 1500 |
Judith Bridges | 4700 | 300 |
Devon Dreymond | 80000 | 2300 |
Ashley Kim | 6000 | 200 |
Table 2: ZylkerEmployeeRelation
Manager | Member |
---|---|
Michelle Mascarenhas | Bruce Kyle |
Michelle Mascarenhas | Clark Kane |
Judith Bridges | Michelle Mascarenhas |
Execute the following command to list the table
copySELECT Managers.Name, Members.Name FROM ZylkerEmployeeCompensation AS Managers INNER JOIN ZylkerEmployeeRelation AS asso ON Managers.ROWID = asso.Manager INNER JOIN ZylkerEmployeeCompensation AS Members ON Members.ROWID = asso.Member
Output:
Manager.Name | Member.Name |
---|---|
Michelle Mascarenhas | Bruce Kyle |
Michelle Mascarenhas | Clark Kane |
Judith Bridges | Michelle Mascarenhas |
-
You can check if you have a NULL value by using the IS/IS NOT operator.The IS/IS NOT operator support is only available for NULL values.
-
When writing GROUP BY with Binaryof() statements, the following ZCQL rules need to be remembered:
- The Binaryof() functionality can only be used in GROUP BY statements.
- Binaryof() can only be used on columns with VarChar or Text datatype.
- When Binaryof() is used in a GROUP BY statement, the returned values are case-sensitive. For example, consider you have the values ‘AMELIA’, ‘amelia’, ‘Burrows’, and ‘burrows’ in a column called Name, in a table called Zylker_EMP. If you use the following command:
copySelect Name from Zylker_EMP group by binaryof(Name)
The result could be any of the following:
- AMELIA
- amelia
- burrows
- Burrows
- Column names can now contain numerical values. You can signify such column names in the query using a backtick (`) punctuation.
For example, a SELECT query on a table called Numbers with a column named 01 can be written in the following manner:
copySELECT `01` FROM Numbers
List of ZCQL Exceptions
The following is a list of common exceptions and example query statements that can trigger these exceptions. Ensure that you go through the list, and follow ZCQL syntax strictly to avoid triggering these exceptions.
Datatype | Case | Sample ZCQL Query | Triggered Exception |
---|---|---|---|
Encrypted Text | Certain operators are not supported | SELECT * FROM temp WHERE enc > 'temsp' | Operator > is not supported for ENCRYPTED TEXT The same exception applies, but the exception message will be altered accordingly if you use these operators <, <=, >= in the ZCQL statement |
LIKE is not supported | SELECT * FROM temp WHERE enc LIKE '*temsp' | Operator LIKE is not supported for ENCRYPTED TEXT The same exception applies, but the exception message will be altered accordingly if you use NOT LIKE in the ZCQL statement |
|
BETWEEN is not supported | SELECT * FROM temp WHERE enc BETWEEN 'one' AND 'ten' | Operator BETWEEN is not supported for ENCRYPTED TEXT The same exception applies, but the exception message will be altered accordingly if you use NOT BETWEEN in the ZCQL statement |
|
IN is not supported | SELECT * FROM temp WHERE enc IN ('one','three') | Operator IN is not supported for ENCRYPTED TEXT The same exception applies if you use NOT IN in your query, but the exception message will be altered accordingly |
|
ZCQL functions is not supported | SELECT AVG(enc) FROM temp | AVG() function is not supported for ENCRYPTED_TEXT ZCQL Functions are not supported in Encrypted Text. |
|
Boolean | Certain operators are not supported | SELECT * FROM temp WHERE bools > FALSE | Operator > is not supported for BOOLEAN
The same exception applies, but the exception message will be altered accordingly if you use these operators <, <=, >= in the ZCQL statement |
LIKE is not supported | SELECT * FROM temp WHERE bools LIKE FALSE | Operator LIKE is not supported for BOOLEAN
The same exception applies if you use NOT LIKE in your query, but the exception message will be altered accordingly |
|
BETWEEN is not supported | SELECT * FROM temp WHERE bools BETWEEN TRUE and FALSE | Operator BETWEEN is not supported for BOOLEAN The same exception applies if you use NOT BETWEEN in your query, but the exception message will be altered accordingly |
|
IN is not supported | SELECT * FROM temp WHERE bools IN (TRUE, FALSE) | Operator IN is not supported for BOOLEAN
The same exception applies if you use NOT IN in your query, but the exception message will be altered accordingly |
|
VarChar | Maximum length exceeded | INSERT INTO temp (Fishes) value (‘salmon’) | ‘salmon’ data too long for column ‘Fishes’
The column Fishes was created as a VarChar and the MaxLength was set as 5. In this statement, ‘Salmon’ exceeds the MaxLength |
Integer | Maximum value exceeded | INSERT INTO temp (numbers) VALUE (546895326908) | For column ‘ints’ INT value should be between -9999999999 and 9999999999 The column numbers was created as INT. The value of INT datatype should be between -9999999999 and 9999999999 |
Big Integer | Maximum value exceeded | INSERT INTO temp (numbers) VALUE (92343432412351 435123453245) |
Given numeric value 92343432412351 435123453 is too large The column numbers was created as BIGINT. The value of BIGINT datatype should be between -9223372036854775808 and 9223372036854775807 |
Text | Value not enclosed in single quotes | SELECT * FROM temp WHERE name = one | Unknown Table temp or Unknown Column one in WHERE The value one will be considered as column if it is not enclosed in quotes—’one’ |
Last Updated 2024-09-03 16:31:06 +0530 +0530
Yes
No
Send your feedback to us