Writing SQL queries using data in Hive
Applies to: Kyvos Enterprise Kyvos Cloud (SaaS on AWS) Kyvos AWS Marketplace
Kyvos Azure Marketplace  Kyvos GCP Marketplace Kyvos Single Node Installation (Kyvos SNI)
You can process a semantic model using Spark SQL. To do this, write an SQL query using tables and views created in Hive. You must choose an HCatalog SQL as a source.
You can also design a dataset based on Hive views. You can use only Spark SQL-supported syntax, clauses, and keywords to fetch data from tables and views created in Hive.
Incremental identifier
Use the incremental identifier to specify the column you want to use to identify and process new data during an incremental process. The data should be sorted in this column or a date column. Kyvos stores the last processed column value with the process.
To register a Hive table, perform the following steps.Â
From the Toolbox, click Datasets.
Click the Actions menu ( ⋮ ), click Add Dataset, enter a name, and then click Add.
Set input type to SQL.
Optionally, you can click the Lookup file checkbox to create a lookup file. Refer to using lookup for details.
Enter SQL code into the editor.Â
(See the code example in this topic.)Optionally, to format and filter data, click Refine.Â
On the Format tab, use the Incremental Identifier field to specify the column you want to use to identify and process new data during an incremental process.
Use the Preview to confirm the results.Â
Click Apply.
Optionally, you can click the Actions menu (...) to validate the data or add a note.
Click Save.
SELECT Sum(lo_extendedprice * lo_discount) AS revenue,
d_yearmonthnum,
lo_discount,
lo_quantity
FROM pdoot.lineorder_v,
pdoot.date_v
WHERE lo_orderdate = d_datekey
AND d_yearmonthnum = 199401
AND lo_discount BETWEEN 4 AND 6
AND lo_quantity BETWEEN 20000 AND 520000
GROUP BY d_yearmonthnum,
lo_discount,
lo_quantity
Example SQL code
To use the SQL editor, perform the following steps.Â
Start typing in the editor box.
As you enter text, suggested statements, functions, operators, and so on, are displayed. Click the item to auto-fill it.
Use the Undo and Redo icons as needed as you create your calculated expression.Â
To find or replace content, click the Find/Replace icon, and enter what to find.
Select Match Case if needed.
If you want to replace the found value, enter the text to replace and specify whether to replace all.
To delete the entry for that item, click the X at the end of the line.
Related topics
Copyright Kyvos, Inc. All rights reserved.