From fccfb06e63eb8c0f7539284c74c448daf4f0c473 Mon Sep 17 00:00:00 2001 From: nenharper Date: Wed, 24 Sep 2025 09:23:28 -0500 Subject: [PATCH 1/4] Purge SQL pages --- .../developers/sql-guide/date-functions.md | 227 ---------- .../developers/sql-guide/features-matrix.md | 88 ---- .../developers/sql-guide/functions.md | 145 ------ .../version-4.5/developers/sql-guide/index.md | 88 ---- .../developers/sql-guide/json-search.md | 177 -------- .../developers/sql-guide/reserved-word.md | 207 --------- .../sql-guide/sql-geospatial-functions.md | 419 ------------------ .../developers/sql-guide/date-functions.md | 227 ---------- .../developers/sql-guide/features-matrix.md | 88 ---- .../developers/sql-guide/functions.md | 145 ------ .../version-4.6/developers/sql-guide/index.md | 88 ---- .../developers/sql-guide/json-search.md | 177 -------- .../developers/sql-guide/reserved-word.md | 207 --------- .../sql-guide/sql-geospatial-functions.md | 419 ------------------ 14 files changed, 2702 deletions(-) delete mode 100644 versioned_docs/version-4.5/developers/sql-guide/date-functions.md delete mode 100644 versioned_docs/version-4.5/developers/sql-guide/features-matrix.md delete mode 100644 versioned_docs/version-4.5/developers/sql-guide/functions.md delete mode 100644 versioned_docs/version-4.5/developers/sql-guide/index.md delete mode 100644 versioned_docs/version-4.5/developers/sql-guide/json-search.md delete mode 100644 versioned_docs/version-4.5/developers/sql-guide/reserved-word.md delete mode 100644 versioned_docs/version-4.5/developers/sql-guide/sql-geospatial-functions.md delete mode 100644 versioned_docs/version-4.6/developers/sql-guide/date-functions.md delete mode 100644 versioned_docs/version-4.6/developers/sql-guide/features-matrix.md delete mode 100644 versioned_docs/version-4.6/developers/sql-guide/functions.md delete mode 100644 versioned_docs/version-4.6/developers/sql-guide/index.md delete mode 100644 versioned_docs/version-4.6/developers/sql-guide/json-search.md delete mode 100644 versioned_docs/version-4.6/developers/sql-guide/reserved-word.md delete mode 100644 versioned_docs/version-4.6/developers/sql-guide/sql-geospatial-functions.md diff --git a/versioned_docs/version-4.5/developers/sql-guide/date-functions.md b/versioned_docs/version-4.5/developers/sql-guide/date-functions.md deleted file mode 100644 index c9747dcd..00000000 --- a/versioned_docs/version-4.5/developers/sql-guide/date-functions.md +++ /dev/null @@ -1,227 +0,0 @@ ---- -title: SQL Date Functions ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# SQL Date Functions - -Harper utilizes [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) in all internal SQL operations. This means that date values passed into any of the functions below will be assumed to be in UTC or in a format that can be translated to UTC. - -When parsing date values passed to SQL date functions in HDB, we first check for [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) formats, then for [RFC 2822](https://tools.ietf.org/html/rfc2822#section-3.3) date-time format and then fall back to new Date(date_string)if a known format is not found. - -### CURRENT_DATE() - -Returns the current date in UTC in `YYYY-MM-DD` String format. - -``` -"SELECT CURRENT_DATE() AS current_date_result" returns - { - "current_date_result": "2020-04-22" - } -``` - -### CURRENT_TIME() - -Returns the current time in UTC in `HH:mm:ss.SSS` String format. - -``` -"SELECT CURRENT_TIME() AS current_time_result" returns - { - "current_time_result": "15:18:14.639" - } -``` - -### CURRENT_TIMESTAMP - -Referencing this variable will evaluate as the current Unix Timestamp in milliseconds. - -``` -"SELECT CURRENT_TIMESTAMP AS current_timestamp_result" returns - { - "current_timestamp_result": 1587568845765 - } -``` - -### DATE([date_string]) - -Formats and returns the date_string argument in UTC in `YYYY-MM-DDTHH:mm:ss.SSSZZ` String format. - -If a date_string is not provided, the function will return the current UTC date/time value in the return format defined above. - -``` -"SELECT DATE(1587568845765) AS date_result" returns - { - "date_result": "2020-04-22T15:20:45.765+0000" - } -``` - -``` -"SELECT DATE(CURRENT_TIMESTAMP) AS date_result2" returns - { - "date_result2": "2020-04-22T15:20:45.765+0000" - } -``` - -### DATE_ADD(date, value, interval) - -Adds the defined amount of time to the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted interval values: Either string value (key or shorthand) can be passed as the interval argument. - -| Key | Shorthand | -| ------------ | --------- | -| years | y | -| quarters | Q | -| months | M | -| weeks | w | -| days | d | -| hours | h | -| minutes | m | -| seconds | s | -| milliseconds | ms | - -``` -"SELECT DATE_ADD(1587568845765, 1, 'days') AS date_add_result" AND -"SELECT DATE_ADD(1587568845765, 1, 'd') AS date_add_result" both return - { - "date_add_result": 1587655245765 - } -``` - -``` -"SELECT DATE_ADD(CURRENT_TIMESTAMP, 2, 'years') -AS date_add_result2" returns - { - "date_add_result2": 1650643129017 - } -``` - -### DATE_DIFF(date_1, date_2[, interval]) - -Returns the difference between the two date values passed based on the interval as a Number. If an interval is not provided, the function will return the difference value in milliseconds. - -Accepted interval values: - -- years -- months -- weeks -- days -- hours -- minutes -- seconds - -``` -"SELECT DATE_DIFF(CURRENT_TIMESTAMP, 1650643129017, 'hours') -AS date_diff_result" returns - { - "date_diff_result": -17519.753333333334 - } -``` - -### DATE_FORMAT(date, format) - -Formats and returns a date value in the String format provided. Find more details on accepted format values in the [moment.js docs](https://momentjs.com/docs/#/displaying/format/). - -``` -"SELECT DATE_FORMAT(1524412627973, 'YYYY-MM-DD HH:mm:ss') -AS date_format_result" returns - { - "date_format_result": "2018-04-22 15:57:07" - } -``` - -### DATE_SUB(date, value, interval) - -Subtracts the defined amount of time from the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted date_sub interval values- Either string value (key or shorthand) can be passed as the interval argument. - -| Key | Shorthand | -| ------------ | --------- | -| years | y | -| quarters | Q | -| months | M | -| weeks | w | -| days | d | -| hours | h | -| minutes | m | -| seconds | s | -| milliseconds | ms | - -``` -"SELECT DATE_SUB(1587568845765, 2, 'years') AS date_sub_result" returns - { - "date_sub_result": 1524410445765 - } -``` - -### EXTRACT(date, date_part) - -Extracts and returns the date_part requested as a String value. Accepted date_part values below show value returned for date = "2020-03-26T15:13:02.041+000" - -| date_part | Example return value\* | -| ----------- | ---------------------- | -| year | "2020" | -| month | "3" | -| day | "26" | -| hour | "15" | -| minute | "13" | -| second | "2" | -| millisecond | "41" | - -``` -"SELECT EXTRACT(1587568845765, 'year') AS extract_result" returns - { - "extract_result": "2020" - } -``` - -### GETDATE() - -Returns the current Unix Timestamp in milliseconds. - -``` -"SELECT GETDATE() AS getdate_result" returns - { - "getdate_result": 1587568845765 - } -``` - -### GET_SERVER_TIME() - -Returns the current date/time value based on the server’s timezone in `YYYY-MM-DDTHH:mm:ss.SSSZZ` String format. - -``` -"SELECT GET_SERVER_TIME() AS get_server_time_result" returns - { - "get_server_time_result": "2020-04-22T15:20:45.765+0000" - } -``` - -### OFFSET_UTC(date, offset) - -Returns the UTC date time value with the offset provided included in the return String value formatted as `YYYY-MM-DDTHH:mm:ss.SSSZZ`. The offset argument will be added as minutes unless the value is less than 16 and greater than -16, in which case it will be treated as hours. - -``` -"SELECT OFFSET_UTC(1587568845765, 240) AS offset_utc_result" returns - { - "offset_utc_result": "2020-04-22T19:20:45.765+0400" - } -``` - -``` -"SELECT OFFSET_UTC(1587568845765, 10) AS offset_utc_result2" returns - { - "offset_utc_result2": "2020-04-23T01:20:45.765+1000" - } -``` - -### NOW() - -Returns the current Unix Timestamp in milliseconds. - -``` -"SELECT NOW() AS now_result" returns - { - "now_result": 1587568845765 - } -``` diff --git a/versioned_docs/version-4.5/developers/sql-guide/features-matrix.md b/versioned_docs/version-4.5/developers/sql-guide/features-matrix.md deleted file mode 100644 index f436ad62..00000000 --- a/versioned_docs/version-4.5/developers/sql-guide/features-matrix.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: SQL Features Matrix ---- - -# SQL Features Matrix - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -## SQL Features Matrix - -Harper provides access to most SQL functions, and we’re always expanding that list. Check below to see if we cover what you need. - -| INSERT | | -| ---------------------------------- | --- | -| Values - multiple values supported | ✔ | -| Sub-SELECT | ✗ | - -| UPDATE | | -| ---------------- | --- | -| SET | ✔ | -| Sub-SELECT | ✗ | -| Conditions | ✔ | -| Date Functions\* | ✔ | -| Math Functions | ✔ | - -| DELETE | | -| ---------- | --- | -| FROM | ✔ | -| Sub-SELECT | ✗ | -| Conditions | ✔ | - -| SELECT | | -| -------------------- | --- | -| Column SELECT | ✔ | -| Aliases | ✔ | -| Aggregator Functions | ✔ | -| Date Functions\* | ✔ | -| Math Functions | ✔ | -| Constant Values | ✔ | -| Distinct | ✔ | -| Sub-SELECT | ✗ | - -| FROM | | -| ---------------- | --- | -| Multi-table JOIN | ✔ | -| INNER JOIN | ✔ | -| LEFT OUTER JOIN | ✔ | -| LEFT INNER JOIN | ✔ | -| RIGHT OUTER JOIN | ✔ | -| RIGHT INNER JOIN | ✔ | -| FULL JOIN | ✔ | -| UNION | ✗ | -| Sub-SELECT | ✗ | -| TOP | ✔ | - -| WHERE | | -| -------------------------- | --- | -| Multi-Conditions | ✔ | -| Wildcards | ✔ | -| IN | ✔ | -| LIKE | ✔ | -| Bit-wise Operators AND, OR | ✔ | -| Bit-wise Operators NOT | ✔ | -| NULL | ✔ | -| BETWEEN | ✔ | -| EXISTS,ANY,ALL | ✔ | -| Compare columns | ✔ | -| Compare constants | ✔ | -| Date Functions\* | ✔ | -| Math Functions | ✔ | -| Sub-SELECT | ✗ | - -| GROUP BY | | -| --------------------- | --- | -| Multi-Column GROUP BY | ✔ | - -| HAVING | | -| ----------------------------- | --- | -| Aggregate function conditions | ✔ | - -| ORDER BY | | -| --------------------- | --- | -| Multi-Column ORDER BY | ✔ | -| Aliases | ✔ | -| Date Functions\* | ✔ | -| Math Functions | ✔ | diff --git a/versioned_docs/version-4.5/developers/sql-guide/functions.md b/versioned_docs/version-4.5/developers/sql-guide/functions.md deleted file mode 100644 index 02fff906..00000000 --- a/versioned_docs/version-4.5/developers/sql-guide/functions.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -title: Harper SQL Functions ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# Harper SQL Functions - -This SQL keywords reference contains the SQL functions available in Harper. - -## Functions - -### Aggregate - -| Keyword | Syntax | Description | -| ------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `AVG` | `AVG(expression)` | Returns the average of a given numeric expression. | -| `COUNT` | `SELECT COUNT(column_name) FROM database.table WHERE condition` | Returns the number records that match the given criteria. Nulls are not counted. | -| `GROUP_CONCAT` | `GROUP_CONCAT(expression)` | Returns a string with concatenated values that are comma separated and that are non-null from a group. Will return null when there are non-null values. | -| `MAX` | `SELECT MAX(column_name) FROM database.table WHERE condition` | Returns largest value in a specified column. | -| `MIN` | `SELECT MIN(column_name) FROM database.table WHERE condition` | Returns smallest value in a specified column. | -| `SUM` | `SUM(column_name)` | Returns the sum of the numeric values provided. | -| `ARRAY`\* | `ARRAY(expression)` | Returns a list of data as a field. | -| `DISTINCT_ARRAY`\* | `DISTINCT_ARRAY(expression)` | When placed around a standard `ARRAY()` function, returns a distinct (deduplicated) results set. | - -\*For more information on `ARRAY()` and `DISTINCT_ARRAY()` see [this blog](https://www.harperdb.io/post/sql-queries-to-complex-objects). - -### Conversion - -| Keyword | Syntax | Description | -| --------- | ----------------------------------------------- | ---------------------------------------------------------------------- | -| `CAST` | `CAST(expression AS datatype(length))` | Converts a value to a specified datatype. | -| `CONVERT` | `CONVERT(data_type(length), expression, style)` | Converts a value from one datatype to a different, specified datatype. | - -### Date & Time - -| Keyword | Syntax | Description | -| ------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `CURRENT_DATE` | `CURRENT_DATE()` | Returns the current date in UTC in "YYYY-MM-DD" String format. | -| `CURRENT_TIME` | `CURRENT_TIME()` | Returns the current time in UTC in "HH:mm:ss.SSS" string format. | -| `CURRENT_TIMESTAMP` | `CURRENT_TIMESTAMP` | Referencing this variable will evaluate as the current Unix Timestamp in milliseconds. For more information, go here. | -| `DATE` | `DATE([date_string])` | Formats and returns the date string argument in UTC in 'YYYY-MM-DDTHH:mm:ss.SSSZZ' string format. If a date string is not provided, the function will return the current UTC date/time value in the return format defined above. For more information, go here. | -| `DATE_ADD` | `DATE_ADD(date, value, interval)` | Adds the defined amount of time to the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted interval values: Either string value (key or shorthand) can be passed as the interval argument. For more information, go here. | -| `DATE_DIFF` | `DATE_DIFF(date_1, date_2[, interval])` | Returns the difference between the two date values passed based on the interval as a Number. If an interval is not provided, the function will return the difference value in milliseconds. For more information, go here. | -| `DATE_FORMAT` | `DATE_FORMAT(date, format)` | Formats and returns a date value in the String format provided. Find more details on accepted format values in the moment.js docs. For more information, go here. | -| `DATE_SUB` | `DATE_SUB(date, format)` | Subtracts the defined amount of time from the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted date_sub interval values- Either string value (key or shorthand) can be passed as the interval argument. For more information, go here. | -| `DAY` | `DAY(date)` | Return the day of the month for the given date. | -| `DAYOFWEEK` | `DAYOFWEEK(date)` | Returns the numeric value of the weekday of the date given("YYYY-MM-DD").NOTE: 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, and 6=Saturday. | -| `EXTRACT` | `EXTRACT(date, date_part)` | Extracts and returns the date part requested as a String value. Accepted date_part values below show value returned for date = "2020-03-26T15:13:02.041+000" For more information, go here. | -| `GETDATE` | `GETDATE()` | Returns the current Unix Timestamp in milliseconds. | -| `GET_SERVER_TIME` | `GET_SERVER_TIME()` | Returns the current date/time value based on the server's timezone in `YYYY-MM-DDTHH:mm:ss.SSSZZ` String format. | -| `OFFSET_UTC` | `OFFSET_UTC(date, offset)` | Returns the UTC date time value with the offset provided included in the return String value formatted as `YYYY-MM-DDTHH:mm:ss.SSSZZ`. The offset argument will be added as minutes unless the value is less than 16 and greater than -16, in which case it will be treated as hours. | -| `NOW` | `NOW()` | Returns the current Unix Timestamp in milliseconds. | -| `HOUR` | `HOUR(datetime)` | Returns the hour part of a given date in range of 0 to 838. | -| `MINUTE` | `MINUTE(datetime)` | Returns the minute part of a time/datetime in range of 0 to 59. | -| `MONTH` | `MONTH(date)` | Returns month part for a specified date in range of 1 to 12. | -| `SECOND` | `SECOND(datetime)` | Returns the seconds part of a time/datetime in range of 0 to 59. | -| `YEAR` | `YEAR(date)` | Returns the year part for a specified date. | - -### Logical - -| Keyword | Syntax | Description | -| -------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------ | -| `IF` | `IF(condition, value_if_true, value_if_false)` | Returns a value if the condition is true, or another value if the condition is false. | -| `IIF` | `IIF(condition, value_if_true, value_if_false)` | Returns a value if the condition is true, or another value if the condition is false. | -| `IFNULL` | `IFNULL(expression, alt_value)` | Returns a specified value if the expression is null. | -| `NULLIF` | `NULLIF(expression_1, expression_2)` | Returns null if expression_1 is equal to expression_2, if not equal, returns expression_1. | - -### Mathematical - -| Keyword | Syntax | Description | -| -------- | ------------------------------- | --------------------------------------------------------------------------------------------------- | -| `ABS` | `ABS(expression)` | Returns the absolute value of a given numeric expression. | -| `CEIL` | `CEIL(number)` | Returns integer ceiling, the smallest integer value that is bigger than or equal to a given number. | -| `EXP` | `EXP(number)` | Returns e to the power of a specified number. | -| `FLOOR` | `FLOOR(number)` | Returns the largest integer value that is smaller than, or equal to, a given number. | -| `RANDOM` | `RANDOM(seed)` | Returns a pseudo random number. | -| `ROUND` | `ROUND(number, decimal_places)` | Rounds a given number to a specified number of decimal places. | -| `SQRT` | `SQRT(expression)` | Returns the square root of an expression. | - -### String - -| Keyword | Syntax | Description | -| ------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `CONCAT` | `CONCAT(string_1, string_2, ...., string_n)` | Concatenates, or joins, two or more strings together, resulting in a single string. | -| `CONCAT_WS` | `CONCAT_WS(separator, string_1, string_2, ...., string_n)` | Concatenates, or joins, two or more strings together with a separator, resulting in a single string. | -| `INSTR` | `INSTR(string_1, string_2)` | Returns the first position, as an integer, of string_2 within string_1. | -| `LEN` | `LEN(string)` | Returns the length of a string. | -| `LOWER` | `LOWER(string)` | Converts a string to lower-case. | -| `REGEXP` | `SELECT column_name FROM database.table WHERE column_name REGEXP pattern` | Searches column for matching string against a given regular expression pattern, provided as a string, and returns all matches. If no matches are found, it returns null. | -| `REGEXP_LIKE` | `SELECT column_name FROM database.table WHERE REGEXP_LIKE(column_name, pattern)` | Searches column for matching string against a given regular expression pattern, provided as a string, and returns all matches. If no matches are found, it returns null. | -| `REPLACE` | `REPLACE(string, old_string, new_string)` | Replaces all instances of old_string within new_string, with string. | -| `SUBSTRING` | `SUBSTRING(string, string_position, length_of_substring)` | Extracts a specified amount of characters from a string. | -| `TRIM` | `TRIM([character(s) FROM] string)` | Removes leading and trailing spaces, or specified character(s), from a string. | -| `UPPER` | `UPPER(string)` | Converts a string to upper-case. | - -## Operators - -### Logical Operators - -| Keyword | Syntax | Description | -| --------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | -| `BETWEEN` | `SELECT column_name(s) FROM database.table WHERE column_name BETWEEN value_1 AND value_2` | (inclusive) Returns values(numbers, text, or dates) within a given range. | -| `IN` | `SELECT column_name(s) FROM database.table WHERE column_name IN(value(s))` | Used to specify multiple values in a WHERE clause. | -| `LIKE` | `SELECT column_name(s) FROM database.table WHERE column_n LIKE pattern` | Searches for a specified pattern within a WHERE clause. | - -## Queries - -### General - -| Keyword | Syntax | Description | -| ---------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | -| `DISTINCT` | `SELECT DISTINCT column_name(s) FROM database.table` | Returns only unique values, eliminating duplicate records. | -| `FROM` | `FROM database.table` | Used to list the database(s), table(s), and any joins required for a SQL statement. | -| `GROUP BY` | `SELECT column_name(s) FROM database.table WHERE condition GROUP BY column_name(s) ORDER BY column_name(s)` | Groups rows that have the same values into summary rows. | -| `HAVING` | `SELECT column_name(s) FROM database.table WHERE condition GROUP BY column_name(s) HAVING condition ORDER BY column_name(s)` | Filters data based on a group or aggregate function. | -| `SELECT` | `SELECT column_name(s) FROM database.table` | Selects data from table. | -| `WHERE` | `SELECT column_name(s) FROM database.table WHERE condition` | Extracts records based on a defined condition. | - -### Joins - -| Keyword | Syntax | Description | -| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `CROSS JOIN` | `SELECT column_name(s) FROM database.table_1 CROSS JOIN database.table_2` | Returns a paired combination of each row from `table_1` with row from `table_2`. Note: CROSS JOIN can return very large result sets and is generally considered bad practice. | -| `FULL OUTER` | `SELECT column_name(s) FROM database.table_1 FULL OUTER JOIN database.table_2 ON table_1.column_name = table_2.column_name WHERE condition` | Returns all records when there is a match in either `table_1` (left table) or `table_2` (right table). | -| `[INNER] JOIN` | `SELECT column_name(s) FROM database.table_1 INNER JOIN database.table_2 ON table_1.column_name = table_2.column_name` | Return only matching records from `table_1` (left table) and `table_2` (right table). The INNER keyword is optional and does not affect the result. | -| `LEFT [OUTER] JOIN` | `SELECT column_name(s) FROM database.table_1 LEFT OUTER JOIN database.table_2 ON table_1.column_name = table_2.column_name` | Return all records from `table_1` (left table) and matching data from `table_2` (right table). The OUTER keyword is optional and does not affect the result. | -| `RIGHT [OUTER] JOIN` | `SELECT column_name(s) FROM database.table_1 RIGHT OUTER JOIN database.table_2 ON table_1.column_name = table_2.column_name` | Return all records from `table_2` (right table) and matching data from `table_1` (left table). The OUTER keyword is optional and does not affect the result. | - -### Predicates - -| Keyword | Syntax | Description | -| ------------- | ------------------------------------------------------------------------- | -------------------------- | -| `IS NOT NULL` | `SELECT column_name(s) FROM database.table WHERE column_name IS NOT NULL` | Tests for non-null values. | -| `IS NULL` | `SELECT column_name(s) FROM database.table WHERE column_name IS NULL` | Tests for null values. | - -### Statements - -| Keyword | Syntax | Description | -| -------- | ---------------------------------------------------------------------------------------- | ----------------------------------- | -| `DELETE` | `DELETE FROM database.table WHERE condition` | Deletes existing data from a table. | -| `INSERT` | `INSERT INTO database.table(column_name(s)) VALUES(value(s))` | Inserts new records into a table. | -| `UPDATE` | `UPDATE database.table SET column_1 = value_1, column_2 = value_2, .... WHERE condition` | Alters existing records in a table. | diff --git a/versioned_docs/version-4.5/developers/sql-guide/index.md b/versioned_docs/version-4.5/developers/sql-guide/index.md deleted file mode 100644 index 52f245ab..00000000 --- a/versioned_docs/version-4.5/developers/sql-guide/index.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: SQL Guide ---- - -# SQL Guide - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -## Harper SQL Guide - -The purpose of this guide is to describe the available functionality of Harper as it relates to supported SQL functionality. The SQL parser is still actively being developed, many SQL features may not be optimized or utilize indexes. This document will be updated as more features and functionality becomes available. Generally, the REST interface provides a more stable, secure, and performant interface for data interaction, but the SQL functionality can be useful for administrative ad-hoc querying, and utilizing existing SQL statements. **A high-level view of supported features can be found** [**here**](sql-guide/features-matrix)**.** - -Harper adheres to the concept of database & tables. This allows developers to isolate table structures from each other all within one database. - -## Select - -Harper has robust SELECT support, from simple queries all the way to complex joins with multi-conditions, aggregates, grouping & ordering. - -All results are returned as JSON object arrays. - -Query for all records and attributes in the dev.dog table: - -``` -SELECT * FROM dev.dog -``` - -Query specific columns from all rows in the dev.dog table: - -``` -SELECT id, dog_name, age FROM dev.dog -``` - -Query for all records and attributes in the dev.dog table ORDERED BY age in ASC order: - -``` -SELECT * FROM dev.dog ORDER BY age -``` - -_The ORDER BY keyword sorts in ascending order by default. To sort in descending order, use the DESC keyword._ - -## Insert - -Harper supports inserting 1 to n records into a table. The primary key must be unique (not used by any other record). If no primary key is provided, it will be assigned an auto-generated UUID. Harper does not support selecting from one table to insert into another at this time. - -``` -INSERT INTO dev.dog (id, dog_name, age, breed_id) - VALUES(1, 'Penny', 5, 347), (2, 'Kato', 4, 347) -``` - -## Update - -Harper supports updating existing table row(s) via UPDATE statements. Multiple conditions can be applied to filter the row(s) to update. At this time selecting from one table to update another is not supported. - -``` -UPDATE dev.dog - SET owner_name = 'Kyle' - WHERE id IN (1, 2) -``` - -## Delete - -Harper supports deleting records from a table with condition support. - -``` -DELETE FROM dev.dog - WHERE age < 4 -``` - -## Joins - -Harper allows developers to join any number of tables and currently supports the following join types: - -- INNER JOIN LEFT -- INNER JOIN LEFT -- OUTER JOIN - -Here’s a basic example joining two tables from our Get Started example- joining a dogs table with a breeds table: - -``` -SELECT d.id, d.dog_name, d.owner_name, b.name, b.section - FROM dev.dog AS d - INNER JOIN dev.breed AS b ON d.breed_id = b.id - WHERE d.owner_name IN ('Kyle', 'Zach', 'Stephen') - AND b.section = 'Mutt' - ORDER BY d.dog_name -``` diff --git a/versioned_docs/version-4.5/developers/sql-guide/json-search.md b/versioned_docs/version-4.5/developers/sql-guide/json-search.md deleted file mode 100644 index c4bcd1c8..00000000 --- a/versioned_docs/version-4.5/developers/sql-guide/json-search.md +++ /dev/null @@ -1,177 +0,0 @@ ---- -title: SQL JSON Search ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# SQL JSON Search - -Harper automatically indexes all top level attributes in a row / object written to a table. However, any attributes which hold JSON data do not have their nested attributes indexed. In order to make searching and/or transforming these JSON documents easy, Harper offers a special SQL function called SEARCH_JSON. The SEARCH_JSON function works in SELECT & WHERE clauses allowing queries to perform powerful filtering on any element of your JSON by implementing the [JSONata library](https://docs.jsonata.org/overview.html) into our SQL engine. - -## Syntax - -`SEARCH_JSON(expression, attribute)` - -Executes the supplied string _expression_ against data of the defined top level _attribute_ for each row. The expression both filters and defines output from the JSON document. - -### Example 1 - -#### Search a string array - -Here are two records in the database: - -```json -[ - { - "id": 1, - "name": ["Harper", "Penny"] - }, - { - "id": 2, - "name": ["Penny"] - } -] -``` - -Here is a simple query that gets any record with "Harper" found in the name. - -``` -SELECT * -FROM dev.dog -WHERE search_json('"Harper" in *', name) -``` - -### Example 2 - -The purpose of this query is to give us every movie where at least two of our favorite actors from Marvel films have acted together. The results will return the movie title, the overview, release date and an object array of the actor’s name and their character name in the movie. - -Both function calls evaluate the credits.cast attribute, this attribute is an object array of every cast member in a movie. - -``` -SELECT m.title, - m.overview, - m.release_date, - SEARCH_JSON($[name in ["Robert Downey Jr.", "Chris Evans", "Scarlett Johansson", "Mark Ruffalo", "Chris Hemsworth", "Jeremy Renner", "Clark Gregg", "Samuel L. Jackson", "Gwyneth Paltrow", "Don Cheadle"]].{"actor": name, "character": character}, c.`cast`) AS characters -FROM movies.credits c - INNER JOIN movies.movie m - ON c.movie_id = m.id -WHERE SEARCH_JSON($count($[name in ["Robert Downey Jr.", "Chris Evans", "Scarlett Johansson", "Mark Ruffalo", "Chris Hemsworth", "Jeremy Renner", "Clark Gregg", "Samuel L. Jackson", "Gwyneth Paltrow", "Don Cheadle"]]), c.`cast`) >= 2 -``` - -A sample of this data from the movie The Avengers looks like - -```json -[ - { - "cast_id": 46, - "character": "Tony Stark / Iron Man", - "credit_id": "52fe4495c3a368484e02b251", - "gender": "male", - "id": 3223, - "name": "Robert Downey Jr.", - "order": 0 - }, - { - "cast_id": 2, - "character": "Steve Rogers / Captain America", - "credit_id": "52fe4495c3a368484e02b19b", - "gender": "male", - "id": 16828, - "name": "Chris Evans", - "order": 1 - }, - { - "cast_id": 307, - "character": "Bruce Banner / The Hulk", - "credit_id": "5e85e8083344c60015411cfa", - "gender": "male", - "id": 103, - "name": "Mark Ruffalo", - "order": 2 - } -] -``` - -Let’s break down the SEARCH_JSON function call in the SELECT: - -``` -SEARCH_JSON( - $[name in [ - "Robert Downey Jr.", - "Chris Evans", - "Scarlett Johansson", - "Mark Ruffalo", - "Chris Hemsworth", - "Jeremy Renner", - "Clark Gregg", - "Samuel L. Jackson", - "Gwyneth Paltrow", - "Don Cheadle" - ]].{ - "actor": name, - "character": character - }, - c.`cast` -) -``` - -The first argument passed to SEARCH_JSON is the expression to execute against the second argument which is the cast attribute on the credits table. This expression will execute for every row. Looking into the expression it starts with "$[…]" this tells the expression to iterate all elements of the cast array. - -Then the expression tells the function to only return entries where the name attribute matches any of the actors defined in the array: - -``` -name in ["Robert Downey Jr.", "Chris Evans", "Scarlett Johansson", "Mark Ruffalo", "Chris Hemsworth", "Jeremy Renner", "Clark Gregg", "Samuel L. Jackson", "Gwyneth Paltrow", "Don Cheadle"] -``` - -So far, we’ve iterated the array and filtered out rows, but we also want the results formatted in a specific way, so we’ve chained an expression on our filter with: `{"actor": name, "character": character}`. This tells the function to create a specific object for each matching entry. - -**Sample Result** - -```json -[ - { - "actor": "Robert Downey Jr.", - "character": "Tony Stark / Iron Man" - }, - { - "actor": "Chris Evans", - "character": "Steve Rogers / Captain America" - }, - { - "actor": "Mark Ruffalo", - "character": "Bruce Banner / The Hulk" - } -] -``` - -Just having the SEARCH_JSON function in our SELECT is powerful, but given our criteria it would still return every other movie that doesn’t have our matching actors, in order to filter out the movies we do not want we also use SEARCH_JSON in the WHERE clause. - -This function call in the WHERE clause is similar, but we don’t need to perform the same transformation as occurred in the SELECT: - -``` -SEARCH_JSON( - $count( - $[name in [ - "Robert Downey Jr.", - "Chris Evans", - "Scarlett Johansson", - "Mark Ruffalo", - "Chris Hemsworth", - "Jeremy Renner", - "Clark Gregg", - "Samuel L. Jackson", - "Gwyneth Paltrow", - "Don Cheadle" - ]] - ), - c.`cast` -) >= 2 -``` - -As seen above we execute the same name filter against the cast array, the primary difference is we are wrapping the filtered results in $count(…). As it looks this returns a count of the results back which we then use against our SQL comparator of >= 2. - -To see further SEARCH_JSON examples in action view our Postman Collection that provides a [sample database & data with query examples](../operations-api/advanced-json-sql-examples). - -To learn more about how to build expressions check out the JSONata documentation: [https://docs.jsonata.org/overview](https://docs.jsonata.org/overview) diff --git a/versioned_docs/version-4.5/developers/sql-guide/reserved-word.md b/versioned_docs/version-4.5/developers/sql-guide/reserved-word.md deleted file mode 100644 index 2cd812ba..00000000 --- a/versioned_docs/version-4.5/developers/sql-guide/reserved-word.md +++ /dev/null @@ -1,207 +0,0 @@ ---- -title: Harper SQL Reserved Words ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# Harper SQL Reserved Words - -This is a list of reserved words in the SQL Parser. Use of these words or symbols may result in unexpected behavior or inaccessible tables/attributes. If any of these words must be used, any SQL call referencing a database, table, or attribute must have backticks (`…`) or brackets ([…]) around the variable. - -For Example, for a table called `ASSERT` in the `data` database, a SQL select on that table would look like: - -``` -SELECT * from data.`ASSERT` -``` - -Alternatively: - -``` -SELECT * from data.[ASSERT] -``` - -### RESERVED WORD LIST - -- ABSOLUTE -- ACTION -- ADD -- AGGR -- ALL -- ALTER -- AND -- ANTI -- ANY -- APPLY -- ARRAY -- AS -- ASSERT -- ASC -- ATTACH -- AUTOINCREMENT -- AUTO_INCREMENT -- AVG -- BEGIN -- BETWEEN -- BREAK -- BY -- CALL -- CASE -- CAST -- CHECK -- CLASS -- CLOSE -- COLLATE -- COLUMN -- COLUMNS -- COMMIT -- CONSTRAINT -- CONTENT -- CONTINUE -- CONVERT -- CORRESPONDING -- COUNT -- CREATE -- CROSS -- CUBE -- CURRENT_TIMESTAMP -- CURSOR -- DATABASE -- DECLARE -- DEFAULT -- DELETE -- DELETED -- DESC -- DETACH -- DISTINCT -- DOUBLEPRECISION -- DROP -- ECHO -- EDGE -- END -- ENUM -- ELSE -- EXCEPT -- EXISTS -- EXPLAIN -- FALSE -- FETCH -- FIRST -- FOREIGN -- FROM -- GO -- GRAPH -- GROUP -- GROUPING -- HAVING -- HDB_HASH -- HELP -- IF -- IDENTITY -- IS -- IN -- INDEX -- INNER -- INSERT -- INSERTED -- INTERSECT -- INTO -- JOIN -- KEY -- LAST -- LET -- LEFT -- LIKE -- LIMIT -- LOOP -- MATCHED -- MATRIX -- MAX -- MERGE -- MIN -- MINUS -- MODIFY -- NATURAL -- NEXT -- NEW -- NOCASE -- NO -- NOT -- NULL -- OFF -- ON -- ONLY -- OFFSET -- OPEN -- OPTION -- OR -- ORDER -- OUTER -- OVER -- PATH -- PARTITION -- PERCENT -- PLAN -- PRIMARY -- PRINT -- PRIOR -- QUERY -- READ -- RECORDSET -- REDUCE -- REFERENCES -- RELATIVE -- REPLACE -- REMOVE -- RENAME -- REQUIRE -- RESTORE -- RETURN -- RETURNS -- RIGHT -- ROLLBACK -- ROLLUP -- ROW -- SCHEMA -- SCHEMAS -- SEARCH -- SELECT -- SEMI -- SET -- SETS -- SHOW -- SOME -- SOURCE -- STRATEGY -- STORE -- SYSTEM -- SUM -- TABLE -- TABLES -- TARGET -- TEMP -- TEMPORARY -- TEXTSTRING -- THEN -- TIMEOUT -- TO -- TOP -- TRAN -- TRANSACTION -- TRIGGER -- TRUE -- TRUNCATE -- UNION -- UNIQUE -- UPDATE -- USE -- USING -- VALUE -- VERTEX -- VIEW -- WHEN -- WHERE -- WHILE -- WITH -- WORK diff --git a/versioned_docs/version-4.5/developers/sql-guide/sql-geospatial-functions.md b/versioned_docs/version-4.5/developers/sql-guide/sql-geospatial-functions.md deleted file mode 100644 index 0c56cf10..00000000 --- a/versioned_docs/version-4.5/developers/sql-guide/sql-geospatial-functions.md +++ /dev/null @@ -1,419 +0,0 @@ ---- -title: SQL Geospatial Functions ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# SQL Geospatial Functions - -Harper geospatial features require data to be stored in a single column using the [GeoJSON standard](https://geojson.org/), a standard commonly used in geospatial technologies. Geospatial functions are available to be used in SQL statements. - -If you are new to GeoJSON you should check out the full specification here: [https://geojson.org/](https://geojson.org/). There are a few important things to point out before getting started. - -1. All GeoJSON coordinates are stored in `[longitude, latitude]` format. -2. Coordinates or GeoJSON geometries must be passed as string when written directly in a SQL statement. -3. Note if you are using Postman for you testing. Due to limitations in the Postman client, you will need to escape quotes in your strings and your SQL will need to be passed on a single line. - -In the examples contained in the left-hand navigation, database and table names may change, but all GeoJSON data will be stored in a column named geo_data. - -# geoArea - -The geoArea() function returns the area of one or more features in square meters. - -### Syntax - -geoArea(_geoJSON_) - -### Parameters - -| Parameter | Description | -| --------- | ------------------------------- | -| geoJSON | Required. One or more features. | - -#### Example 1 - -Calculate the area, in square meters, of a manually passed GeoJSON polygon. - -``` -SELECT geoArea('{ - "type":"Feature", - "geometry":{ - "type":"Polygon", - "coordinates":[[ - [0,0], - [0.123456,0], - [0.123456,0.123456], - [0,0.123456] - ]] - } -}') -``` - -#### Example 2 - -Find all records that have an area less than 1 square mile (or 2589988 square meters). - -``` -SELECT * FROM dev.locations -WHERE geoArea(geo_data) < 2589988 -``` - -# geoLength - -Takes a GeoJSON and measures its length in the specified units (default is kilometers). - -## Syntax - -geoLength(_geoJSON_[_, units_]) - -## Parameters - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------------------------------------------- | -| geoJSON | Required. GeoJSON to measure. | -| units | Optional. Specified as a string. Options are ‘degrees’, ‘radians’, ‘miles’, or ‘kilometers’. Default is ‘kilometers’. | - -### Example 1 - -Calculate the length, in kilometers, of a manually passed GeoJSON linestring. - -``` -SELECT geoLength('{ - "type": "Feature", - "geometry": { - "type": "LineString", - "coordinates": [ - [-104.97963309288025,39.76163265441438], - [-104.9823260307312,39.76365323407955], - [-104.99193906784058,39.75616442110704] - ] - } -}') -``` - -### Example 2 - -Find all data plus the calculated length in miles of the GeoJSON, restrict the response to only lengths less than 5 miles, and return the data in order of lengths smallest to largest. - -``` -SELECT *, geoLength(geo_data, 'miles') as length -FROM dev.locations -WHERE geoLength(geo_data, 'miles') < 5 -ORDER BY length ASC -``` - -# geoDifference - -Returns a new polygon with the difference of the second polygon clipped from the first polygon. - -## Syntax - -geoDifference(_polygon1, polygon2_) - -## Parameters - -| Parameter | Description | -| --------- | -------------------------------------------------------------------------- | -| polygon1 | Required. Polygon or MultiPolygon GeoJSON feature. | -| polygon2 | Required. Polygon or MultiPolygon GeoJSON feature to remove from polygon1. | - -### Example - -Return a GeoJSON Polygon that removes City Park (_polygon2_) from Colorado (_polygon1_). - -``` -SELECT geoDifference('{ - "type": "Feature", - "properties": { - "name":"Colorado" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-109.072265625,37.00255267215955], - [-102.01904296874999,37.00255267215955], - [-102.01904296874999,41.0130657870063], - [-109.072265625,41.0130657870063], - [-109.072265625,37.00255267215955] - ]] - } - }', - '{ - "type": "Feature", - "properties": { - "name":"City Park" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-104.95973110198975,39.7543828214657], - [-104.95955944061278,39.744781185675386], - [-104.95904445648193,39.74422022399989], - [-104.95835781097412,39.74402223643582], - [-104.94097709655762,39.74392324244047], - [-104.9408483505249,39.75434982844515], - [-104.95973110198975,39.7543828214657] - ]] - } - }' -) -``` - -# geoDistance - -Calculates the distance between two points in units (default is kilometers). - -## Syntax - -geoDistance(_point1, point2_[_, units_]) - -## Parameters - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------------------------------------------- | -| point1 | Required. GeoJSON Point specifying the origin. | -| point2 | Required. GeoJSON Point specifying the destination. | -| units | Optional. Specified as a string. Options are ‘degrees’, ‘radians’, ‘miles’, or ‘kilometers’. Default is ‘kilometers’. | - -### Example 1 - -Calculate the distance, in miles, between Harper’s headquarters and the Washington Monument. - -``` -SELECT geoDistance('[-104.979127,39.761563]', '[-77.035248,38.889475]', 'miles') -``` - -### Example 2 - -Find all locations that are within 40 kilometers of a given point, return that distance in miles, and sort by distance in an ascending order. - -``` -SELECT *, geoDistance('[-104.979127,39.761563]', geo_data, 'miles') as distance -FROM dev.locations -WHERE geoDistance('[-104.979127,39.761563]', geo_data, 'kilometers') < 40 -ORDER BY distance ASC -``` - -# geoNear - -Determines if point1 and point2 are within a specified distance from each other, default units are kilometers. Returns a Boolean. - -## Syntax - -geoNear(_point1, point2, distance_[_, units_]) - -## Parameters - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------------------------------------------- | -| point1 | Required. GeoJSON Point specifying the origin. | -| point2 | Required. GeoJSON Point specifying the destination. | -| distance | Required. The maximum distance in units as an integer or decimal. | -| units | Optional. Specified as a string. Options are ‘degrees’, ‘radians’, ‘miles’, or ‘kilometers’. Default is ‘kilometers’. | - -### Example 1 - -Return all locations within 50 miles of a given point. - -``` -SELECT * -FROM dev.locations -WHERE geoNear('[-104.979127,39.761563]', geo_data, 50, 'miles') -``` - -### Example 2 - -Return all locations within 2 degrees of the earth of a given point. (Each degree lat/long is about 69 miles [111 kilometers]). Return all data and the distance in miles, sorted by ascending distance. - -``` -SELECT *, geoDistance('[-104.979127,39.761563]', geo_data, 'miles') as distance -FROM dev.locations -WHERE geoNear('[-104.979127,39.761563]', geo_data, 2, 'degrees') -ORDER BY distance ASC -``` - -# geoContains - -Determines if geo2 is completely contained by geo1. Returns a Boolean. - -## Syntax - -geoContains(_geo1, geo2_) - -## Parameters - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------- | -| geo1 | Required. Polygon or MultiPolygon GeoJSON feature. | -| geo2 | Required. Polygon or MultiPolygon GeoJSON feature tested to be contained by geo1. | - -### Example 1 - -Return all locations within the state of Colorado (passed as a GeoJSON string). - -``` -SELECT * -FROM dev.locations -WHERE geoContains('{ - "type": "Feature", - "properties": { - "name":"Colorado" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-109.072265625,37.00255267], - [-102.01904296874999,37.00255267], - [-102.01904296874999,41.01306579], - [-109.072265625,41.01306579], - [-109.072265625,37.00255267] - ]] - } -}', geo_data) -``` - -### Example 2 - -Return all locations which contain Harper Headquarters. - -``` -SELECT * -FROM dev.locations -WHERE geoContains(geo_data, '{ - "type": "Feature", - "properties": { - "name": "Harper Headquarters" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-104.98060941696167,39.760704817357905], - [-104.98053967952728,39.76065120861263], - [-104.98055577278137,39.760642961109674], - [-104.98037070035934,39.76049450588716], - [-104.9802714586258,39.76056254790385], - [-104.9805235862732,39.76076461167841], - [-104.98060941696167,39.760704817357905] - ]] - } -}') -``` - -# geoEqual - -Determines if two GeoJSON features are the same type and have identical X,Y coordinate values. For more information see [https://developers.arcgis.com/documentation/spatial-references/](https://developers.arcgis.com/documentation/spatial-references/). Returns a Boolean. - -## Syntax - -geoEqual(_geo1_, _geo2_) - -## Parameters - -| Parameter | Description | -| --------- | -------------------------------------- | -| geo1 | Required. GeoJSON geometry or feature. | -| geo2 | Required. GeoJSON geometry or feature. | - -### Example - -Find Harper Headquarters within all locations within the database. - -``` -SELECT * -FROM dev.locations -WHERE geoEqual(geo_data, '{ - "type": "Feature", - "properties": { - "name": "Harper Headquarters" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-104.98060941696167,39.760704817357905], - [-104.98053967952728,39.76065120861263], - [-104.98055577278137,39.760642961109674], - [-104.98037070035934,39.76049450588716], - [-104.9802714586258,39.76056254790385], - [-104.9805235862732,39.76076461167841], - [-104.98060941696167,39.760704817357905] - ]] - } -}') -``` - -# geoCrosses - -Determines if the geometries cross over each other. Returns boolean. - -## Syntax - -geoCrosses(_geo1, geo2_) - -## Parameters - -| Parameter | Description | -| --------- | -------------------------------------- | -| geo1 | Required. GeoJSON geometry or feature. | -| geo2 | Required. GeoJSON geometry or feature. | - -### Example - -Find all locations that cross over a highway. - -``` -SELECT * -FROM dev.locations -WHERE geoCrosses( - geo_data, - '{ - "type": "Feature", - "properties": { - "name": "Highway I-25" - }, - "geometry": { - "type": "LineString", - "coordinates": [ - [-104.9139404296875,41.00477542222947], - [-105.0238037109375,39.715638134796336], - [-104.853515625,39.53370327008705], - [-104.853515625,38.81403111409755], - [-104.61181640625,38.39764411353178], - [-104.8974609375,37.68382032669382], - [-104.501953125,37.00255267215955] - ] - } - }' -) -``` - -# geoConvert - -Converts a series of coordinates into a GeoJSON of the specified type. - -## Syntax - -geoConvert(_coordinates, geo_type_[, _properties_]) - -## Parameters - -| Parameter | Description | -| ----------- | ---------------------------------------------------------------------------------------------------------------------------------- | -| coordinates | Required. One or more coordinates | -| geo_type | Required. GeoJSON geometry type. Options are ‘point’, ‘lineString’, ‘multiLineString’, ‘multiPoint’, ‘multiPolygon’, and ‘polygon’ | -| properties | Optional. Escaped JSON array with properties to be added to the GeoJSON output. | - -### Example - -Convert a given coordinate into a GeoJSON point with specified properties. - -``` -SELECT geoConvert( - '[-104.979127,39.761563]', - 'point', - '{ - "name": "Harper Headquarters" - }' -) -``` diff --git a/versioned_docs/version-4.6/developers/sql-guide/date-functions.md b/versioned_docs/version-4.6/developers/sql-guide/date-functions.md deleted file mode 100644 index c9747dcd..00000000 --- a/versioned_docs/version-4.6/developers/sql-guide/date-functions.md +++ /dev/null @@ -1,227 +0,0 @@ ---- -title: SQL Date Functions ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# SQL Date Functions - -Harper utilizes [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) in all internal SQL operations. This means that date values passed into any of the functions below will be assumed to be in UTC or in a format that can be translated to UTC. - -When parsing date values passed to SQL date functions in HDB, we first check for [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) formats, then for [RFC 2822](https://tools.ietf.org/html/rfc2822#section-3.3) date-time format and then fall back to new Date(date_string)if a known format is not found. - -### CURRENT_DATE() - -Returns the current date in UTC in `YYYY-MM-DD` String format. - -``` -"SELECT CURRENT_DATE() AS current_date_result" returns - { - "current_date_result": "2020-04-22" - } -``` - -### CURRENT_TIME() - -Returns the current time in UTC in `HH:mm:ss.SSS` String format. - -``` -"SELECT CURRENT_TIME() AS current_time_result" returns - { - "current_time_result": "15:18:14.639" - } -``` - -### CURRENT_TIMESTAMP - -Referencing this variable will evaluate as the current Unix Timestamp in milliseconds. - -``` -"SELECT CURRENT_TIMESTAMP AS current_timestamp_result" returns - { - "current_timestamp_result": 1587568845765 - } -``` - -### DATE([date_string]) - -Formats and returns the date_string argument in UTC in `YYYY-MM-DDTHH:mm:ss.SSSZZ` String format. - -If a date_string is not provided, the function will return the current UTC date/time value in the return format defined above. - -``` -"SELECT DATE(1587568845765) AS date_result" returns - { - "date_result": "2020-04-22T15:20:45.765+0000" - } -``` - -``` -"SELECT DATE(CURRENT_TIMESTAMP) AS date_result2" returns - { - "date_result2": "2020-04-22T15:20:45.765+0000" - } -``` - -### DATE_ADD(date, value, interval) - -Adds the defined amount of time to the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted interval values: Either string value (key or shorthand) can be passed as the interval argument. - -| Key | Shorthand | -| ------------ | --------- | -| years | y | -| quarters | Q | -| months | M | -| weeks | w | -| days | d | -| hours | h | -| minutes | m | -| seconds | s | -| milliseconds | ms | - -``` -"SELECT DATE_ADD(1587568845765, 1, 'days') AS date_add_result" AND -"SELECT DATE_ADD(1587568845765, 1, 'd') AS date_add_result" both return - { - "date_add_result": 1587655245765 - } -``` - -``` -"SELECT DATE_ADD(CURRENT_TIMESTAMP, 2, 'years') -AS date_add_result2" returns - { - "date_add_result2": 1650643129017 - } -``` - -### DATE_DIFF(date_1, date_2[, interval]) - -Returns the difference between the two date values passed based on the interval as a Number. If an interval is not provided, the function will return the difference value in milliseconds. - -Accepted interval values: - -- years -- months -- weeks -- days -- hours -- minutes -- seconds - -``` -"SELECT DATE_DIFF(CURRENT_TIMESTAMP, 1650643129017, 'hours') -AS date_diff_result" returns - { - "date_diff_result": -17519.753333333334 - } -``` - -### DATE_FORMAT(date, format) - -Formats and returns a date value in the String format provided. Find more details on accepted format values in the [moment.js docs](https://momentjs.com/docs/#/displaying/format/). - -``` -"SELECT DATE_FORMAT(1524412627973, 'YYYY-MM-DD HH:mm:ss') -AS date_format_result" returns - { - "date_format_result": "2018-04-22 15:57:07" - } -``` - -### DATE_SUB(date, value, interval) - -Subtracts the defined amount of time from the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted date_sub interval values- Either string value (key or shorthand) can be passed as the interval argument. - -| Key | Shorthand | -| ------------ | --------- | -| years | y | -| quarters | Q | -| months | M | -| weeks | w | -| days | d | -| hours | h | -| minutes | m | -| seconds | s | -| milliseconds | ms | - -``` -"SELECT DATE_SUB(1587568845765, 2, 'years') AS date_sub_result" returns - { - "date_sub_result": 1524410445765 - } -``` - -### EXTRACT(date, date_part) - -Extracts and returns the date_part requested as a String value. Accepted date_part values below show value returned for date = "2020-03-26T15:13:02.041+000" - -| date_part | Example return value\* | -| ----------- | ---------------------- | -| year | "2020" | -| month | "3" | -| day | "26" | -| hour | "15" | -| minute | "13" | -| second | "2" | -| millisecond | "41" | - -``` -"SELECT EXTRACT(1587568845765, 'year') AS extract_result" returns - { - "extract_result": "2020" - } -``` - -### GETDATE() - -Returns the current Unix Timestamp in milliseconds. - -``` -"SELECT GETDATE() AS getdate_result" returns - { - "getdate_result": 1587568845765 - } -``` - -### GET_SERVER_TIME() - -Returns the current date/time value based on the server’s timezone in `YYYY-MM-DDTHH:mm:ss.SSSZZ` String format. - -``` -"SELECT GET_SERVER_TIME() AS get_server_time_result" returns - { - "get_server_time_result": "2020-04-22T15:20:45.765+0000" - } -``` - -### OFFSET_UTC(date, offset) - -Returns the UTC date time value with the offset provided included in the return String value formatted as `YYYY-MM-DDTHH:mm:ss.SSSZZ`. The offset argument will be added as minutes unless the value is less than 16 and greater than -16, in which case it will be treated as hours. - -``` -"SELECT OFFSET_UTC(1587568845765, 240) AS offset_utc_result" returns - { - "offset_utc_result": "2020-04-22T19:20:45.765+0400" - } -``` - -``` -"SELECT OFFSET_UTC(1587568845765, 10) AS offset_utc_result2" returns - { - "offset_utc_result2": "2020-04-23T01:20:45.765+1000" - } -``` - -### NOW() - -Returns the current Unix Timestamp in milliseconds. - -``` -"SELECT NOW() AS now_result" returns - { - "now_result": 1587568845765 - } -``` diff --git a/versioned_docs/version-4.6/developers/sql-guide/features-matrix.md b/versioned_docs/version-4.6/developers/sql-guide/features-matrix.md deleted file mode 100644 index f436ad62..00000000 --- a/versioned_docs/version-4.6/developers/sql-guide/features-matrix.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: SQL Features Matrix ---- - -# SQL Features Matrix - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -## SQL Features Matrix - -Harper provides access to most SQL functions, and we’re always expanding that list. Check below to see if we cover what you need. - -| INSERT | | -| ---------------------------------- | --- | -| Values - multiple values supported | ✔ | -| Sub-SELECT | ✗ | - -| UPDATE | | -| ---------------- | --- | -| SET | ✔ | -| Sub-SELECT | ✗ | -| Conditions | ✔ | -| Date Functions\* | ✔ | -| Math Functions | ✔ | - -| DELETE | | -| ---------- | --- | -| FROM | ✔ | -| Sub-SELECT | ✗ | -| Conditions | ✔ | - -| SELECT | | -| -------------------- | --- | -| Column SELECT | ✔ | -| Aliases | ✔ | -| Aggregator Functions | ✔ | -| Date Functions\* | ✔ | -| Math Functions | ✔ | -| Constant Values | ✔ | -| Distinct | ✔ | -| Sub-SELECT | ✗ | - -| FROM | | -| ---------------- | --- | -| Multi-table JOIN | ✔ | -| INNER JOIN | ✔ | -| LEFT OUTER JOIN | ✔ | -| LEFT INNER JOIN | ✔ | -| RIGHT OUTER JOIN | ✔ | -| RIGHT INNER JOIN | ✔ | -| FULL JOIN | ✔ | -| UNION | ✗ | -| Sub-SELECT | ✗ | -| TOP | ✔ | - -| WHERE | | -| -------------------------- | --- | -| Multi-Conditions | ✔ | -| Wildcards | ✔ | -| IN | ✔ | -| LIKE | ✔ | -| Bit-wise Operators AND, OR | ✔ | -| Bit-wise Operators NOT | ✔ | -| NULL | ✔ | -| BETWEEN | ✔ | -| EXISTS,ANY,ALL | ✔ | -| Compare columns | ✔ | -| Compare constants | ✔ | -| Date Functions\* | ✔ | -| Math Functions | ✔ | -| Sub-SELECT | ✗ | - -| GROUP BY | | -| --------------------- | --- | -| Multi-Column GROUP BY | ✔ | - -| HAVING | | -| ----------------------------- | --- | -| Aggregate function conditions | ✔ | - -| ORDER BY | | -| --------------------- | --- | -| Multi-Column ORDER BY | ✔ | -| Aliases | ✔ | -| Date Functions\* | ✔ | -| Math Functions | ✔ | diff --git a/versioned_docs/version-4.6/developers/sql-guide/functions.md b/versioned_docs/version-4.6/developers/sql-guide/functions.md deleted file mode 100644 index 02fff906..00000000 --- a/versioned_docs/version-4.6/developers/sql-guide/functions.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -title: Harper SQL Functions ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# Harper SQL Functions - -This SQL keywords reference contains the SQL functions available in Harper. - -## Functions - -### Aggregate - -| Keyword | Syntax | Description | -| ------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `AVG` | `AVG(expression)` | Returns the average of a given numeric expression. | -| `COUNT` | `SELECT COUNT(column_name) FROM database.table WHERE condition` | Returns the number records that match the given criteria. Nulls are not counted. | -| `GROUP_CONCAT` | `GROUP_CONCAT(expression)` | Returns a string with concatenated values that are comma separated and that are non-null from a group. Will return null when there are non-null values. | -| `MAX` | `SELECT MAX(column_name) FROM database.table WHERE condition` | Returns largest value in a specified column. | -| `MIN` | `SELECT MIN(column_name) FROM database.table WHERE condition` | Returns smallest value in a specified column. | -| `SUM` | `SUM(column_name)` | Returns the sum of the numeric values provided. | -| `ARRAY`\* | `ARRAY(expression)` | Returns a list of data as a field. | -| `DISTINCT_ARRAY`\* | `DISTINCT_ARRAY(expression)` | When placed around a standard `ARRAY()` function, returns a distinct (deduplicated) results set. | - -\*For more information on `ARRAY()` and `DISTINCT_ARRAY()` see [this blog](https://www.harperdb.io/post/sql-queries-to-complex-objects). - -### Conversion - -| Keyword | Syntax | Description | -| --------- | ----------------------------------------------- | ---------------------------------------------------------------------- | -| `CAST` | `CAST(expression AS datatype(length))` | Converts a value to a specified datatype. | -| `CONVERT` | `CONVERT(data_type(length), expression, style)` | Converts a value from one datatype to a different, specified datatype. | - -### Date & Time - -| Keyword | Syntax | Description | -| ------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `CURRENT_DATE` | `CURRENT_DATE()` | Returns the current date in UTC in "YYYY-MM-DD" String format. | -| `CURRENT_TIME` | `CURRENT_TIME()` | Returns the current time in UTC in "HH:mm:ss.SSS" string format. | -| `CURRENT_TIMESTAMP` | `CURRENT_TIMESTAMP` | Referencing this variable will evaluate as the current Unix Timestamp in milliseconds. For more information, go here. | -| `DATE` | `DATE([date_string])` | Formats and returns the date string argument in UTC in 'YYYY-MM-DDTHH:mm:ss.SSSZZ' string format. If a date string is not provided, the function will return the current UTC date/time value in the return format defined above. For more information, go here. | -| `DATE_ADD` | `DATE_ADD(date, value, interval)` | Adds the defined amount of time to the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted interval values: Either string value (key or shorthand) can be passed as the interval argument. For more information, go here. | -| `DATE_DIFF` | `DATE_DIFF(date_1, date_2[, interval])` | Returns the difference between the two date values passed based on the interval as a Number. If an interval is not provided, the function will return the difference value in milliseconds. For more information, go here. | -| `DATE_FORMAT` | `DATE_FORMAT(date, format)` | Formats and returns a date value in the String format provided. Find more details on accepted format values in the moment.js docs. For more information, go here. | -| `DATE_SUB` | `DATE_SUB(date, format)` | Subtracts the defined amount of time from the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted date_sub interval values- Either string value (key or shorthand) can be passed as the interval argument. For more information, go here. | -| `DAY` | `DAY(date)` | Return the day of the month for the given date. | -| `DAYOFWEEK` | `DAYOFWEEK(date)` | Returns the numeric value of the weekday of the date given("YYYY-MM-DD").NOTE: 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, and 6=Saturday. | -| `EXTRACT` | `EXTRACT(date, date_part)` | Extracts and returns the date part requested as a String value. Accepted date_part values below show value returned for date = "2020-03-26T15:13:02.041+000" For more information, go here. | -| `GETDATE` | `GETDATE()` | Returns the current Unix Timestamp in milliseconds. | -| `GET_SERVER_TIME` | `GET_SERVER_TIME()` | Returns the current date/time value based on the server's timezone in `YYYY-MM-DDTHH:mm:ss.SSSZZ` String format. | -| `OFFSET_UTC` | `OFFSET_UTC(date, offset)` | Returns the UTC date time value with the offset provided included in the return String value formatted as `YYYY-MM-DDTHH:mm:ss.SSSZZ`. The offset argument will be added as minutes unless the value is less than 16 and greater than -16, in which case it will be treated as hours. | -| `NOW` | `NOW()` | Returns the current Unix Timestamp in milliseconds. | -| `HOUR` | `HOUR(datetime)` | Returns the hour part of a given date in range of 0 to 838. | -| `MINUTE` | `MINUTE(datetime)` | Returns the minute part of a time/datetime in range of 0 to 59. | -| `MONTH` | `MONTH(date)` | Returns month part for a specified date in range of 1 to 12. | -| `SECOND` | `SECOND(datetime)` | Returns the seconds part of a time/datetime in range of 0 to 59. | -| `YEAR` | `YEAR(date)` | Returns the year part for a specified date. | - -### Logical - -| Keyword | Syntax | Description | -| -------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------ | -| `IF` | `IF(condition, value_if_true, value_if_false)` | Returns a value if the condition is true, or another value if the condition is false. | -| `IIF` | `IIF(condition, value_if_true, value_if_false)` | Returns a value if the condition is true, or another value if the condition is false. | -| `IFNULL` | `IFNULL(expression, alt_value)` | Returns a specified value if the expression is null. | -| `NULLIF` | `NULLIF(expression_1, expression_2)` | Returns null if expression_1 is equal to expression_2, if not equal, returns expression_1. | - -### Mathematical - -| Keyword | Syntax | Description | -| -------- | ------------------------------- | --------------------------------------------------------------------------------------------------- | -| `ABS` | `ABS(expression)` | Returns the absolute value of a given numeric expression. | -| `CEIL` | `CEIL(number)` | Returns integer ceiling, the smallest integer value that is bigger than or equal to a given number. | -| `EXP` | `EXP(number)` | Returns e to the power of a specified number. | -| `FLOOR` | `FLOOR(number)` | Returns the largest integer value that is smaller than, or equal to, a given number. | -| `RANDOM` | `RANDOM(seed)` | Returns a pseudo random number. | -| `ROUND` | `ROUND(number, decimal_places)` | Rounds a given number to a specified number of decimal places. | -| `SQRT` | `SQRT(expression)` | Returns the square root of an expression. | - -### String - -| Keyword | Syntax | Description | -| ------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `CONCAT` | `CONCAT(string_1, string_2, ...., string_n)` | Concatenates, or joins, two or more strings together, resulting in a single string. | -| `CONCAT_WS` | `CONCAT_WS(separator, string_1, string_2, ...., string_n)` | Concatenates, or joins, two or more strings together with a separator, resulting in a single string. | -| `INSTR` | `INSTR(string_1, string_2)` | Returns the first position, as an integer, of string_2 within string_1. | -| `LEN` | `LEN(string)` | Returns the length of a string. | -| `LOWER` | `LOWER(string)` | Converts a string to lower-case. | -| `REGEXP` | `SELECT column_name FROM database.table WHERE column_name REGEXP pattern` | Searches column for matching string against a given regular expression pattern, provided as a string, and returns all matches. If no matches are found, it returns null. | -| `REGEXP_LIKE` | `SELECT column_name FROM database.table WHERE REGEXP_LIKE(column_name, pattern)` | Searches column for matching string against a given regular expression pattern, provided as a string, and returns all matches. If no matches are found, it returns null. | -| `REPLACE` | `REPLACE(string, old_string, new_string)` | Replaces all instances of old_string within new_string, with string. | -| `SUBSTRING` | `SUBSTRING(string, string_position, length_of_substring)` | Extracts a specified amount of characters from a string. | -| `TRIM` | `TRIM([character(s) FROM] string)` | Removes leading and trailing spaces, or specified character(s), from a string. | -| `UPPER` | `UPPER(string)` | Converts a string to upper-case. | - -## Operators - -### Logical Operators - -| Keyword | Syntax | Description | -| --------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | -| `BETWEEN` | `SELECT column_name(s) FROM database.table WHERE column_name BETWEEN value_1 AND value_2` | (inclusive) Returns values(numbers, text, or dates) within a given range. | -| `IN` | `SELECT column_name(s) FROM database.table WHERE column_name IN(value(s))` | Used to specify multiple values in a WHERE clause. | -| `LIKE` | `SELECT column_name(s) FROM database.table WHERE column_n LIKE pattern` | Searches for a specified pattern within a WHERE clause. | - -## Queries - -### General - -| Keyword | Syntax | Description | -| ---------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | -| `DISTINCT` | `SELECT DISTINCT column_name(s) FROM database.table` | Returns only unique values, eliminating duplicate records. | -| `FROM` | `FROM database.table` | Used to list the database(s), table(s), and any joins required for a SQL statement. | -| `GROUP BY` | `SELECT column_name(s) FROM database.table WHERE condition GROUP BY column_name(s) ORDER BY column_name(s)` | Groups rows that have the same values into summary rows. | -| `HAVING` | `SELECT column_name(s) FROM database.table WHERE condition GROUP BY column_name(s) HAVING condition ORDER BY column_name(s)` | Filters data based on a group or aggregate function. | -| `SELECT` | `SELECT column_name(s) FROM database.table` | Selects data from table. | -| `WHERE` | `SELECT column_name(s) FROM database.table WHERE condition` | Extracts records based on a defined condition. | - -### Joins - -| Keyword | Syntax | Description | -| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `CROSS JOIN` | `SELECT column_name(s) FROM database.table_1 CROSS JOIN database.table_2` | Returns a paired combination of each row from `table_1` with row from `table_2`. Note: CROSS JOIN can return very large result sets and is generally considered bad practice. | -| `FULL OUTER` | `SELECT column_name(s) FROM database.table_1 FULL OUTER JOIN database.table_2 ON table_1.column_name = table_2.column_name WHERE condition` | Returns all records when there is a match in either `table_1` (left table) or `table_2` (right table). | -| `[INNER] JOIN` | `SELECT column_name(s) FROM database.table_1 INNER JOIN database.table_2 ON table_1.column_name = table_2.column_name` | Return only matching records from `table_1` (left table) and `table_2` (right table). The INNER keyword is optional and does not affect the result. | -| `LEFT [OUTER] JOIN` | `SELECT column_name(s) FROM database.table_1 LEFT OUTER JOIN database.table_2 ON table_1.column_name = table_2.column_name` | Return all records from `table_1` (left table) and matching data from `table_2` (right table). The OUTER keyword is optional and does not affect the result. | -| `RIGHT [OUTER] JOIN` | `SELECT column_name(s) FROM database.table_1 RIGHT OUTER JOIN database.table_2 ON table_1.column_name = table_2.column_name` | Return all records from `table_2` (right table) and matching data from `table_1` (left table). The OUTER keyword is optional and does not affect the result. | - -### Predicates - -| Keyword | Syntax | Description | -| ------------- | ------------------------------------------------------------------------- | -------------------------- | -| `IS NOT NULL` | `SELECT column_name(s) FROM database.table WHERE column_name IS NOT NULL` | Tests for non-null values. | -| `IS NULL` | `SELECT column_name(s) FROM database.table WHERE column_name IS NULL` | Tests for null values. | - -### Statements - -| Keyword | Syntax | Description | -| -------- | ---------------------------------------------------------------------------------------- | ----------------------------------- | -| `DELETE` | `DELETE FROM database.table WHERE condition` | Deletes existing data from a table. | -| `INSERT` | `INSERT INTO database.table(column_name(s)) VALUES(value(s))` | Inserts new records into a table. | -| `UPDATE` | `UPDATE database.table SET column_1 = value_1, column_2 = value_2, .... WHERE condition` | Alters existing records in a table. | diff --git a/versioned_docs/version-4.6/developers/sql-guide/index.md b/versioned_docs/version-4.6/developers/sql-guide/index.md deleted file mode 100644 index 52f245ab..00000000 --- a/versioned_docs/version-4.6/developers/sql-guide/index.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: SQL Guide ---- - -# SQL Guide - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -## Harper SQL Guide - -The purpose of this guide is to describe the available functionality of Harper as it relates to supported SQL functionality. The SQL parser is still actively being developed, many SQL features may not be optimized or utilize indexes. This document will be updated as more features and functionality becomes available. Generally, the REST interface provides a more stable, secure, and performant interface for data interaction, but the SQL functionality can be useful for administrative ad-hoc querying, and utilizing existing SQL statements. **A high-level view of supported features can be found** [**here**](sql-guide/features-matrix)**.** - -Harper adheres to the concept of database & tables. This allows developers to isolate table structures from each other all within one database. - -## Select - -Harper has robust SELECT support, from simple queries all the way to complex joins with multi-conditions, aggregates, grouping & ordering. - -All results are returned as JSON object arrays. - -Query for all records and attributes in the dev.dog table: - -``` -SELECT * FROM dev.dog -``` - -Query specific columns from all rows in the dev.dog table: - -``` -SELECT id, dog_name, age FROM dev.dog -``` - -Query for all records and attributes in the dev.dog table ORDERED BY age in ASC order: - -``` -SELECT * FROM dev.dog ORDER BY age -``` - -_The ORDER BY keyword sorts in ascending order by default. To sort in descending order, use the DESC keyword._ - -## Insert - -Harper supports inserting 1 to n records into a table. The primary key must be unique (not used by any other record). If no primary key is provided, it will be assigned an auto-generated UUID. Harper does not support selecting from one table to insert into another at this time. - -``` -INSERT INTO dev.dog (id, dog_name, age, breed_id) - VALUES(1, 'Penny', 5, 347), (2, 'Kato', 4, 347) -``` - -## Update - -Harper supports updating existing table row(s) via UPDATE statements. Multiple conditions can be applied to filter the row(s) to update. At this time selecting from one table to update another is not supported. - -``` -UPDATE dev.dog - SET owner_name = 'Kyle' - WHERE id IN (1, 2) -``` - -## Delete - -Harper supports deleting records from a table with condition support. - -``` -DELETE FROM dev.dog - WHERE age < 4 -``` - -## Joins - -Harper allows developers to join any number of tables and currently supports the following join types: - -- INNER JOIN LEFT -- INNER JOIN LEFT -- OUTER JOIN - -Here’s a basic example joining two tables from our Get Started example- joining a dogs table with a breeds table: - -``` -SELECT d.id, d.dog_name, d.owner_name, b.name, b.section - FROM dev.dog AS d - INNER JOIN dev.breed AS b ON d.breed_id = b.id - WHERE d.owner_name IN ('Kyle', 'Zach', 'Stephen') - AND b.section = 'Mutt' - ORDER BY d.dog_name -``` diff --git a/versioned_docs/version-4.6/developers/sql-guide/json-search.md b/versioned_docs/version-4.6/developers/sql-guide/json-search.md deleted file mode 100644 index c4bcd1c8..00000000 --- a/versioned_docs/version-4.6/developers/sql-guide/json-search.md +++ /dev/null @@ -1,177 +0,0 @@ ---- -title: SQL JSON Search ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# SQL JSON Search - -Harper automatically indexes all top level attributes in a row / object written to a table. However, any attributes which hold JSON data do not have their nested attributes indexed. In order to make searching and/or transforming these JSON documents easy, Harper offers a special SQL function called SEARCH_JSON. The SEARCH_JSON function works in SELECT & WHERE clauses allowing queries to perform powerful filtering on any element of your JSON by implementing the [JSONata library](https://docs.jsonata.org/overview.html) into our SQL engine. - -## Syntax - -`SEARCH_JSON(expression, attribute)` - -Executes the supplied string _expression_ against data of the defined top level _attribute_ for each row. The expression both filters and defines output from the JSON document. - -### Example 1 - -#### Search a string array - -Here are two records in the database: - -```json -[ - { - "id": 1, - "name": ["Harper", "Penny"] - }, - { - "id": 2, - "name": ["Penny"] - } -] -``` - -Here is a simple query that gets any record with "Harper" found in the name. - -``` -SELECT * -FROM dev.dog -WHERE search_json('"Harper" in *', name) -``` - -### Example 2 - -The purpose of this query is to give us every movie where at least two of our favorite actors from Marvel films have acted together. The results will return the movie title, the overview, release date and an object array of the actor’s name and their character name in the movie. - -Both function calls evaluate the credits.cast attribute, this attribute is an object array of every cast member in a movie. - -``` -SELECT m.title, - m.overview, - m.release_date, - SEARCH_JSON($[name in ["Robert Downey Jr.", "Chris Evans", "Scarlett Johansson", "Mark Ruffalo", "Chris Hemsworth", "Jeremy Renner", "Clark Gregg", "Samuel L. Jackson", "Gwyneth Paltrow", "Don Cheadle"]].{"actor": name, "character": character}, c.`cast`) AS characters -FROM movies.credits c - INNER JOIN movies.movie m - ON c.movie_id = m.id -WHERE SEARCH_JSON($count($[name in ["Robert Downey Jr.", "Chris Evans", "Scarlett Johansson", "Mark Ruffalo", "Chris Hemsworth", "Jeremy Renner", "Clark Gregg", "Samuel L. Jackson", "Gwyneth Paltrow", "Don Cheadle"]]), c.`cast`) >= 2 -``` - -A sample of this data from the movie The Avengers looks like - -```json -[ - { - "cast_id": 46, - "character": "Tony Stark / Iron Man", - "credit_id": "52fe4495c3a368484e02b251", - "gender": "male", - "id": 3223, - "name": "Robert Downey Jr.", - "order": 0 - }, - { - "cast_id": 2, - "character": "Steve Rogers / Captain America", - "credit_id": "52fe4495c3a368484e02b19b", - "gender": "male", - "id": 16828, - "name": "Chris Evans", - "order": 1 - }, - { - "cast_id": 307, - "character": "Bruce Banner / The Hulk", - "credit_id": "5e85e8083344c60015411cfa", - "gender": "male", - "id": 103, - "name": "Mark Ruffalo", - "order": 2 - } -] -``` - -Let’s break down the SEARCH_JSON function call in the SELECT: - -``` -SEARCH_JSON( - $[name in [ - "Robert Downey Jr.", - "Chris Evans", - "Scarlett Johansson", - "Mark Ruffalo", - "Chris Hemsworth", - "Jeremy Renner", - "Clark Gregg", - "Samuel L. Jackson", - "Gwyneth Paltrow", - "Don Cheadle" - ]].{ - "actor": name, - "character": character - }, - c.`cast` -) -``` - -The first argument passed to SEARCH_JSON is the expression to execute against the second argument which is the cast attribute on the credits table. This expression will execute for every row. Looking into the expression it starts with "$[…]" this tells the expression to iterate all elements of the cast array. - -Then the expression tells the function to only return entries where the name attribute matches any of the actors defined in the array: - -``` -name in ["Robert Downey Jr.", "Chris Evans", "Scarlett Johansson", "Mark Ruffalo", "Chris Hemsworth", "Jeremy Renner", "Clark Gregg", "Samuel L. Jackson", "Gwyneth Paltrow", "Don Cheadle"] -``` - -So far, we’ve iterated the array and filtered out rows, but we also want the results formatted in a specific way, so we’ve chained an expression on our filter with: `{"actor": name, "character": character}`. This tells the function to create a specific object for each matching entry. - -**Sample Result** - -```json -[ - { - "actor": "Robert Downey Jr.", - "character": "Tony Stark / Iron Man" - }, - { - "actor": "Chris Evans", - "character": "Steve Rogers / Captain America" - }, - { - "actor": "Mark Ruffalo", - "character": "Bruce Banner / The Hulk" - } -] -``` - -Just having the SEARCH_JSON function in our SELECT is powerful, but given our criteria it would still return every other movie that doesn’t have our matching actors, in order to filter out the movies we do not want we also use SEARCH_JSON in the WHERE clause. - -This function call in the WHERE clause is similar, but we don’t need to perform the same transformation as occurred in the SELECT: - -``` -SEARCH_JSON( - $count( - $[name in [ - "Robert Downey Jr.", - "Chris Evans", - "Scarlett Johansson", - "Mark Ruffalo", - "Chris Hemsworth", - "Jeremy Renner", - "Clark Gregg", - "Samuel L. Jackson", - "Gwyneth Paltrow", - "Don Cheadle" - ]] - ), - c.`cast` -) >= 2 -``` - -As seen above we execute the same name filter against the cast array, the primary difference is we are wrapping the filtered results in $count(…). As it looks this returns a count of the results back which we then use against our SQL comparator of >= 2. - -To see further SEARCH_JSON examples in action view our Postman Collection that provides a [sample database & data with query examples](../operations-api/advanced-json-sql-examples). - -To learn more about how to build expressions check out the JSONata documentation: [https://docs.jsonata.org/overview](https://docs.jsonata.org/overview) diff --git a/versioned_docs/version-4.6/developers/sql-guide/reserved-word.md b/versioned_docs/version-4.6/developers/sql-guide/reserved-word.md deleted file mode 100644 index 2cd812ba..00000000 --- a/versioned_docs/version-4.6/developers/sql-guide/reserved-word.md +++ /dev/null @@ -1,207 +0,0 @@ ---- -title: Harper SQL Reserved Words ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# Harper SQL Reserved Words - -This is a list of reserved words in the SQL Parser. Use of these words or symbols may result in unexpected behavior or inaccessible tables/attributes. If any of these words must be used, any SQL call referencing a database, table, or attribute must have backticks (`…`) or brackets ([…]) around the variable. - -For Example, for a table called `ASSERT` in the `data` database, a SQL select on that table would look like: - -``` -SELECT * from data.`ASSERT` -``` - -Alternatively: - -``` -SELECT * from data.[ASSERT] -``` - -### RESERVED WORD LIST - -- ABSOLUTE -- ACTION -- ADD -- AGGR -- ALL -- ALTER -- AND -- ANTI -- ANY -- APPLY -- ARRAY -- AS -- ASSERT -- ASC -- ATTACH -- AUTOINCREMENT -- AUTO_INCREMENT -- AVG -- BEGIN -- BETWEEN -- BREAK -- BY -- CALL -- CASE -- CAST -- CHECK -- CLASS -- CLOSE -- COLLATE -- COLUMN -- COLUMNS -- COMMIT -- CONSTRAINT -- CONTENT -- CONTINUE -- CONVERT -- CORRESPONDING -- COUNT -- CREATE -- CROSS -- CUBE -- CURRENT_TIMESTAMP -- CURSOR -- DATABASE -- DECLARE -- DEFAULT -- DELETE -- DELETED -- DESC -- DETACH -- DISTINCT -- DOUBLEPRECISION -- DROP -- ECHO -- EDGE -- END -- ENUM -- ELSE -- EXCEPT -- EXISTS -- EXPLAIN -- FALSE -- FETCH -- FIRST -- FOREIGN -- FROM -- GO -- GRAPH -- GROUP -- GROUPING -- HAVING -- HDB_HASH -- HELP -- IF -- IDENTITY -- IS -- IN -- INDEX -- INNER -- INSERT -- INSERTED -- INTERSECT -- INTO -- JOIN -- KEY -- LAST -- LET -- LEFT -- LIKE -- LIMIT -- LOOP -- MATCHED -- MATRIX -- MAX -- MERGE -- MIN -- MINUS -- MODIFY -- NATURAL -- NEXT -- NEW -- NOCASE -- NO -- NOT -- NULL -- OFF -- ON -- ONLY -- OFFSET -- OPEN -- OPTION -- OR -- ORDER -- OUTER -- OVER -- PATH -- PARTITION -- PERCENT -- PLAN -- PRIMARY -- PRINT -- PRIOR -- QUERY -- READ -- RECORDSET -- REDUCE -- REFERENCES -- RELATIVE -- REPLACE -- REMOVE -- RENAME -- REQUIRE -- RESTORE -- RETURN -- RETURNS -- RIGHT -- ROLLBACK -- ROLLUP -- ROW -- SCHEMA -- SCHEMAS -- SEARCH -- SELECT -- SEMI -- SET -- SETS -- SHOW -- SOME -- SOURCE -- STRATEGY -- STORE -- SYSTEM -- SUM -- TABLE -- TABLES -- TARGET -- TEMP -- TEMPORARY -- TEXTSTRING -- THEN -- TIMEOUT -- TO -- TOP -- TRAN -- TRANSACTION -- TRIGGER -- TRUE -- TRUNCATE -- UNION -- UNIQUE -- UPDATE -- USE -- USING -- VALUE -- VERTEX -- VIEW -- WHEN -- WHERE -- WHILE -- WITH -- WORK diff --git a/versioned_docs/version-4.6/developers/sql-guide/sql-geospatial-functions.md b/versioned_docs/version-4.6/developers/sql-guide/sql-geospatial-functions.md deleted file mode 100644 index bf7f542f..00000000 --- a/versioned_docs/version-4.6/developers/sql-guide/sql-geospatial-functions.md +++ /dev/null @@ -1,419 +0,0 @@ ---- -title: SQL Geospatial Functions ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# SQL Geospatial Functions - -Harper geospatial features require data to be stored in a single column using the [GeoJSON standard](https://geojson.org/), a standard commonly used in geospatial technologies. Geospatial functions are available to be used in SQL statements. - -If you are new to GeoJSON you should check out the full specification here: [https://geojson.org/](https://geojson.org/). There are a few important things to point out before getting started. - -1. All GeoJSON coordinates are stored in `[longitude, latitude]` format. -1. Coordinates or GeoJSON geometries must be passed as string when written directly in a SQL statement. -1. Note if you are using Postman for you testing. Due to limitations in the Postman client, you will need to escape quotes in your strings and your SQL will need to be passed on a single line. - -In the examples contained in the left-hand navigation, database and table names may change, but all GeoJSON data will be stored in a column named geo_data. - -# geoArea - -The geoArea() function returns the area of one or more features in square meters. - -### Syntax - -geoArea(_geoJSON_) - -### Parameters - -| Parameter | Description | -| --------- | ------------------------------- | -| geoJSON | Required. One or more features. | - -#### Example 1 - -Calculate the area, in square meters, of a manually passed GeoJSON polygon. - -``` -SELECT geoArea('{ - "type":"Feature", - "geometry":{ - "type":"Polygon", - "coordinates":[[ - [0,0], - [0.123456,0], - [0.123456,0.123456], - [0,0.123456] - ]] - } -}') -``` - -#### Example 2 - -Find all records that have an area less than 1 square mile (or 2589988 square meters). - -``` -SELECT * FROM dev.locations -WHERE geoArea(geo_data) < 2589988 -``` - -# geoLength - -Takes a GeoJSON and measures its length in the specified units (default is kilometers). - -## Syntax - -geoLength(_geoJSON_[_, units_]) - -## Parameters - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------------------------------------------- | -| geoJSON | Required. GeoJSON to measure. | -| units | Optional. Specified as a string. Options are ‘degrees’, ‘radians’, ‘miles’, or ‘kilometers’. Default is ‘kilometers’. | - -### Example 1 - -Calculate the length, in kilometers, of a manually passed GeoJSON linestring. - -``` -SELECT geoLength('{ - "type": "Feature", - "geometry": { - "type": "LineString", - "coordinates": [ - [-104.97963309288025,39.76163265441438], - [-104.9823260307312,39.76365323407955], - [-104.99193906784058,39.75616442110704] - ] - } -}') -``` - -### Example 2 - -Find all data plus the calculated length in miles of the GeoJSON, restrict the response to only lengths less than 5 miles, and return the data in order of lengths smallest to largest. - -``` -SELECT *, geoLength(geo_data, 'miles') as length -FROM dev.locations -WHERE geoLength(geo_data, 'miles') < 5 -ORDER BY length ASC -``` - -# geoDifference - -Returns a new polygon with the difference of the second polygon clipped from the first polygon. - -## Syntax - -geoDifference(_polygon1, polygon2_) - -## Parameters - -| Parameter | Description | -| --------- | -------------------------------------------------------------------------- | -| polygon1 | Required. Polygon or MultiPolygon GeoJSON feature. | -| polygon2 | Required. Polygon or MultiPolygon GeoJSON feature to remove from polygon1. | - -### Example - -Return a GeoJSON Polygon that removes City Park (_polygon2_) from Colorado (_polygon1_). - -``` -SELECT geoDifference('{ - "type": "Feature", - "properties": { - "name":"Colorado" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-109.072265625,37.00255267215955], - [-102.01904296874999,37.00255267215955], - [-102.01904296874999,41.0130657870063], - [-109.072265625,41.0130657870063], - [-109.072265625,37.00255267215955] - ]] - } - }', - '{ - "type": "Feature", - "properties": { - "name":"City Park" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-104.95973110198975,39.7543828214657], - [-104.95955944061278,39.744781185675386], - [-104.95904445648193,39.74422022399989], - [-104.95835781097412,39.74402223643582], - [-104.94097709655762,39.74392324244047], - [-104.9408483505249,39.75434982844515], - [-104.95973110198975,39.7543828214657] - ]] - } - }' -) -``` - -# geoDistance - -Calculates the distance between two points in units (default is kilometers). - -## Syntax - -geoDistance(_point1, point2_[_, units_]) - -## Parameters - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------------------------------------------- | -| point1 | Required. GeoJSON Point specifying the origin. | -| point2 | Required. GeoJSON Point specifying the destination. | -| units | Optional. Specified as a string. Options are ‘degrees’, ‘radians’, ‘miles’, or ‘kilometers’. Default is ‘kilometers’. | - -### Example 1 - -Calculate the distance, in miles, between Harper’s headquarters and the Washington Monument. - -``` -SELECT geoDistance('[-104.979127,39.761563]', '[-77.035248,38.889475]', 'miles') -``` - -### Example 2 - -Find all locations that are within 40 kilometers of a given point, return that distance in miles, and sort by distance in an ascending order. - -``` -SELECT *, geoDistance('[-104.979127,39.761563]', geo_data, 'miles') as distance -FROM dev.locations -WHERE geoDistance('[-104.979127,39.761563]', geo_data, 'kilometers') < 40 -ORDER BY distance ASC -``` - -# geoNear - -Determines if point1 and point2 are within a specified distance from each other, default units are kilometers. Returns a Boolean. - -## Syntax - -geoNear(_point1, point2, distance_[_, units_]) - -## Parameters - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------------------------------------------- | -| point1 | Required. GeoJSON Point specifying the origin. | -| point2 | Required. GeoJSON Point specifying the destination. | -| distance | Required. The maximum distance in units as an integer or decimal. | -| units | Optional. Specified as a string. Options are ‘degrees’, ‘radians’, ‘miles’, or ‘kilometers’. Default is ‘kilometers’. | - -### Example 1 - -Return all locations within 50 miles of a given point. - -``` -SELECT * -FROM dev.locations -WHERE geoNear('[-104.979127,39.761563]', geo_data, 50, 'miles') -``` - -### Example 2 - -Return all locations within 2 degrees of the earth of a given point. (Each degree lat/long is about 69 miles [111 kilometers]). Return all data and the distance in miles, sorted by ascending distance. - -``` -SELECT *, geoDistance('[-104.979127,39.761563]', geo_data, 'miles') as distance -FROM dev.locations -WHERE geoNear('[-104.979127,39.761563]', geo_data, 2, 'degrees') -ORDER BY distance ASC -``` - -# geoContains - -Determines if geo2 is completely contained by geo1. Returns a Boolean. - -## Syntax - -geoContains(_geo1, geo2_) - -## Parameters - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------- | -| geo1 | Required. Polygon or MultiPolygon GeoJSON feature. | -| geo2 | Required. Polygon or MultiPolygon GeoJSON feature tested to be contained by geo1. | - -### Example 1 - -Return all locations within the state of Colorado (passed as a GeoJSON string). - -``` -SELECT * -FROM dev.locations -WHERE geoContains('{ - "type": "Feature", - "properties": { - "name":"Colorado" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-109.072265625,37.00255267], - [-102.01904296874999,37.00255267], - [-102.01904296874999,41.01306579], - [-109.072265625,41.01306579], - [-109.072265625,37.00255267] - ]] - } -}', geo_data) -``` - -### Example 2 - -Return all locations which contain Harper Headquarters. - -``` -SELECT * -FROM dev.locations -WHERE geoContains(geo_data, '{ - "type": "Feature", - "properties": { - "name": "Harper Headquarters" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-104.98060941696167,39.760704817357905], - [-104.98053967952728,39.76065120861263], - [-104.98055577278137,39.760642961109674], - [-104.98037070035934,39.76049450588716], - [-104.9802714586258,39.76056254790385], - [-104.9805235862732,39.76076461167841], - [-104.98060941696167,39.760704817357905] - ]] - } -}') -``` - -# geoEqual - -Determines if two GeoJSON features are the same type and have identical X,Y coordinate values. For more information see [https://developers.arcgis.com/documentation/spatial-references/](https://developers.arcgis.com/documentation/spatial-references/). Returns a Boolean. - -## Syntax - -geoEqual(_geo1_, _geo2_) - -## Parameters - -| Parameter | Description | -| --------- | -------------------------------------- | -| geo1 | Required. GeoJSON geometry or feature. | -| geo2 | Required. GeoJSON geometry or feature. | - -### Example - -Find Harper Headquarters within all locations within the database. - -``` -SELECT * -FROM dev.locations -WHERE geoEqual(geo_data, '{ - "type": "Feature", - "properties": { - "name": "Harper Headquarters" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-104.98060941696167,39.760704817357905], - [-104.98053967952728,39.76065120861263], - [-104.98055577278137,39.760642961109674], - [-104.98037070035934,39.76049450588716], - [-104.9802714586258,39.76056254790385], - [-104.9805235862732,39.76076461167841], - [-104.98060941696167,39.760704817357905] - ]] - } -}') -``` - -# geoCrosses - -Determines if the geometries cross over each other. Returns boolean. - -## Syntax - -geoCrosses(_geo1, geo2_) - -## Parameters - -| Parameter | Description | -| --------- | -------------------------------------- | -| geo1 | Required. GeoJSON geometry or feature. | -| geo2 | Required. GeoJSON geometry or feature. | - -### Example - -Find all locations that cross over a highway. - -``` -SELECT * -FROM dev.locations -WHERE geoCrosses( - geo_data, - '{ - "type": "Feature", - "properties": { - "name": "Highway I-25" - }, - "geometry": { - "type": "LineString", - "coordinates": [ - [-104.9139404296875,41.00477542222947], - [-105.0238037109375,39.715638134796336], - [-104.853515625,39.53370327008705], - [-104.853515625,38.81403111409755], - [-104.61181640625,38.39764411353178], - [-104.8974609375,37.68382032669382], - [-104.501953125,37.00255267215955] - ] - } - }' -) -``` - -# geoConvert - -Converts a series of coordinates into a GeoJSON of the specified type. - -## Syntax - -geoConvert(_coordinates, geo_type_[, _properties_]) - -## Parameters - -| Parameter | Description | -| ----------- | ---------------------------------------------------------------------------------------------------------------------------------- | -| coordinates | Required. One or more coordinates | -| geo_type | Required. GeoJSON geometry type. Options are ‘point’, ‘lineString’, ‘multiLineString’, ‘multiPoint’, ‘multiPolygon’, and ‘polygon’ | -| properties | Optional. Escaped JSON array with properties to be added to the GeoJSON output. | - -### Example - -Convert a given coordinate into a GeoJSON point with specified properties. - -``` -SELECT geoConvert( - '[-104.979127,39.761563]', - 'point', - '{ - "name": "Harper Headquarters" - }' -) -``` From 0afe6df4c45ac30b0413b3bd5f559b5fd9fadd21 Mon Sep 17 00:00:00 2001 From: nenharper Date: Thu, 25 Sep 2025 11:55:42 -0500 Subject: [PATCH 2/4] Remove from doc dir --- docs/developers/sql-guide/date-functions.md | 227 ---------- docs/developers/sql-guide/features-matrix.md | 88 ---- docs/developers/sql-guide/functions.md | 145 ------ docs/developers/sql-guide/index.md | 88 ---- docs/developers/sql-guide/json-search.md | 177 -------- docs/developers/sql-guide/reserved-word.md | 207 --------- .../sql-guide/sql-geospatial-functions.md | 419 ------------------ 7 files changed, 1351 deletions(-) delete mode 100644 docs/developers/sql-guide/date-functions.md delete mode 100644 docs/developers/sql-guide/features-matrix.md delete mode 100644 docs/developers/sql-guide/functions.md delete mode 100644 docs/developers/sql-guide/index.md delete mode 100644 docs/developers/sql-guide/json-search.md delete mode 100644 docs/developers/sql-guide/reserved-word.md delete mode 100644 docs/developers/sql-guide/sql-geospatial-functions.md diff --git a/docs/developers/sql-guide/date-functions.md b/docs/developers/sql-guide/date-functions.md deleted file mode 100644 index c9747dcd..00000000 --- a/docs/developers/sql-guide/date-functions.md +++ /dev/null @@ -1,227 +0,0 @@ ---- -title: SQL Date Functions ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# SQL Date Functions - -Harper utilizes [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) in all internal SQL operations. This means that date values passed into any of the functions below will be assumed to be in UTC or in a format that can be translated to UTC. - -When parsing date values passed to SQL date functions in HDB, we first check for [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) formats, then for [RFC 2822](https://tools.ietf.org/html/rfc2822#section-3.3) date-time format and then fall back to new Date(date_string)if a known format is not found. - -### CURRENT_DATE() - -Returns the current date in UTC in `YYYY-MM-DD` String format. - -``` -"SELECT CURRENT_DATE() AS current_date_result" returns - { - "current_date_result": "2020-04-22" - } -``` - -### CURRENT_TIME() - -Returns the current time in UTC in `HH:mm:ss.SSS` String format. - -``` -"SELECT CURRENT_TIME() AS current_time_result" returns - { - "current_time_result": "15:18:14.639" - } -``` - -### CURRENT_TIMESTAMP - -Referencing this variable will evaluate as the current Unix Timestamp in milliseconds. - -``` -"SELECT CURRENT_TIMESTAMP AS current_timestamp_result" returns - { - "current_timestamp_result": 1587568845765 - } -``` - -### DATE([date_string]) - -Formats and returns the date_string argument in UTC in `YYYY-MM-DDTHH:mm:ss.SSSZZ` String format. - -If a date_string is not provided, the function will return the current UTC date/time value in the return format defined above. - -``` -"SELECT DATE(1587568845765) AS date_result" returns - { - "date_result": "2020-04-22T15:20:45.765+0000" - } -``` - -``` -"SELECT DATE(CURRENT_TIMESTAMP) AS date_result2" returns - { - "date_result2": "2020-04-22T15:20:45.765+0000" - } -``` - -### DATE_ADD(date, value, interval) - -Adds the defined amount of time to the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted interval values: Either string value (key or shorthand) can be passed as the interval argument. - -| Key | Shorthand | -| ------------ | --------- | -| years | y | -| quarters | Q | -| months | M | -| weeks | w | -| days | d | -| hours | h | -| minutes | m | -| seconds | s | -| milliseconds | ms | - -``` -"SELECT DATE_ADD(1587568845765, 1, 'days') AS date_add_result" AND -"SELECT DATE_ADD(1587568845765, 1, 'd') AS date_add_result" both return - { - "date_add_result": 1587655245765 - } -``` - -``` -"SELECT DATE_ADD(CURRENT_TIMESTAMP, 2, 'years') -AS date_add_result2" returns - { - "date_add_result2": 1650643129017 - } -``` - -### DATE_DIFF(date_1, date_2[, interval]) - -Returns the difference between the two date values passed based on the interval as a Number. If an interval is not provided, the function will return the difference value in milliseconds. - -Accepted interval values: - -- years -- months -- weeks -- days -- hours -- minutes -- seconds - -``` -"SELECT DATE_DIFF(CURRENT_TIMESTAMP, 1650643129017, 'hours') -AS date_diff_result" returns - { - "date_diff_result": -17519.753333333334 - } -``` - -### DATE_FORMAT(date, format) - -Formats and returns a date value in the String format provided. Find more details on accepted format values in the [moment.js docs](https://momentjs.com/docs/#/displaying/format/). - -``` -"SELECT DATE_FORMAT(1524412627973, 'YYYY-MM-DD HH:mm:ss') -AS date_format_result" returns - { - "date_format_result": "2018-04-22 15:57:07" - } -``` - -### DATE_SUB(date, value, interval) - -Subtracts the defined amount of time from the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted date_sub interval values- Either string value (key or shorthand) can be passed as the interval argument. - -| Key | Shorthand | -| ------------ | --------- | -| years | y | -| quarters | Q | -| months | M | -| weeks | w | -| days | d | -| hours | h | -| minutes | m | -| seconds | s | -| milliseconds | ms | - -``` -"SELECT DATE_SUB(1587568845765, 2, 'years') AS date_sub_result" returns - { - "date_sub_result": 1524410445765 - } -``` - -### EXTRACT(date, date_part) - -Extracts and returns the date_part requested as a String value. Accepted date_part values below show value returned for date = "2020-03-26T15:13:02.041+000" - -| date_part | Example return value\* | -| ----------- | ---------------------- | -| year | "2020" | -| month | "3" | -| day | "26" | -| hour | "15" | -| minute | "13" | -| second | "2" | -| millisecond | "41" | - -``` -"SELECT EXTRACT(1587568845765, 'year') AS extract_result" returns - { - "extract_result": "2020" - } -``` - -### GETDATE() - -Returns the current Unix Timestamp in milliseconds. - -``` -"SELECT GETDATE() AS getdate_result" returns - { - "getdate_result": 1587568845765 - } -``` - -### GET_SERVER_TIME() - -Returns the current date/time value based on the server’s timezone in `YYYY-MM-DDTHH:mm:ss.SSSZZ` String format. - -``` -"SELECT GET_SERVER_TIME() AS get_server_time_result" returns - { - "get_server_time_result": "2020-04-22T15:20:45.765+0000" - } -``` - -### OFFSET_UTC(date, offset) - -Returns the UTC date time value with the offset provided included in the return String value formatted as `YYYY-MM-DDTHH:mm:ss.SSSZZ`. The offset argument will be added as minutes unless the value is less than 16 and greater than -16, in which case it will be treated as hours. - -``` -"SELECT OFFSET_UTC(1587568845765, 240) AS offset_utc_result" returns - { - "offset_utc_result": "2020-04-22T19:20:45.765+0400" - } -``` - -``` -"SELECT OFFSET_UTC(1587568845765, 10) AS offset_utc_result2" returns - { - "offset_utc_result2": "2020-04-23T01:20:45.765+1000" - } -``` - -### NOW() - -Returns the current Unix Timestamp in milliseconds. - -``` -"SELECT NOW() AS now_result" returns - { - "now_result": 1587568845765 - } -``` diff --git a/docs/developers/sql-guide/features-matrix.md b/docs/developers/sql-guide/features-matrix.md deleted file mode 100644 index f436ad62..00000000 --- a/docs/developers/sql-guide/features-matrix.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: SQL Features Matrix ---- - -# SQL Features Matrix - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -## SQL Features Matrix - -Harper provides access to most SQL functions, and we’re always expanding that list. Check below to see if we cover what you need. - -| INSERT | | -| ---------------------------------- | --- | -| Values - multiple values supported | ✔ | -| Sub-SELECT | ✗ | - -| UPDATE | | -| ---------------- | --- | -| SET | ✔ | -| Sub-SELECT | ✗ | -| Conditions | ✔ | -| Date Functions\* | ✔ | -| Math Functions | ✔ | - -| DELETE | | -| ---------- | --- | -| FROM | ✔ | -| Sub-SELECT | ✗ | -| Conditions | ✔ | - -| SELECT | | -| -------------------- | --- | -| Column SELECT | ✔ | -| Aliases | ✔ | -| Aggregator Functions | ✔ | -| Date Functions\* | ✔ | -| Math Functions | ✔ | -| Constant Values | ✔ | -| Distinct | ✔ | -| Sub-SELECT | ✗ | - -| FROM | | -| ---------------- | --- | -| Multi-table JOIN | ✔ | -| INNER JOIN | ✔ | -| LEFT OUTER JOIN | ✔ | -| LEFT INNER JOIN | ✔ | -| RIGHT OUTER JOIN | ✔ | -| RIGHT INNER JOIN | ✔ | -| FULL JOIN | ✔ | -| UNION | ✗ | -| Sub-SELECT | ✗ | -| TOP | ✔ | - -| WHERE | | -| -------------------------- | --- | -| Multi-Conditions | ✔ | -| Wildcards | ✔ | -| IN | ✔ | -| LIKE | ✔ | -| Bit-wise Operators AND, OR | ✔ | -| Bit-wise Operators NOT | ✔ | -| NULL | ✔ | -| BETWEEN | ✔ | -| EXISTS,ANY,ALL | ✔ | -| Compare columns | ✔ | -| Compare constants | ✔ | -| Date Functions\* | ✔ | -| Math Functions | ✔ | -| Sub-SELECT | ✗ | - -| GROUP BY | | -| --------------------- | --- | -| Multi-Column GROUP BY | ✔ | - -| HAVING | | -| ----------------------------- | --- | -| Aggregate function conditions | ✔ | - -| ORDER BY | | -| --------------------- | --- | -| Multi-Column ORDER BY | ✔ | -| Aliases | ✔ | -| Date Functions\* | ✔ | -| Math Functions | ✔ | diff --git a/docs/developers/sql-guide/functions.md b/docs/developers/sql-guide/functions.md deleted file mode 100644 index 789090a4..00000000 --- a/docs/developers/sql-guide/functions.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -title: Harper SQL Functions ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# Harper SQL Functions - -This SQL keywords reference contains the SQL functions available in Harper. - -## Functions - -### Aggregate - -| Keyword | Syntax | Description | -| ------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `AVG` | `AVG(expression)` | Returns the average of a given numeric expression. | -| `COUNT` | `SELECT COUNT(column_name) FROM database.table WHERE condition` | Returns the number records that match the given criteria. Nulls are not counted. | -| `GROUP_CONCAT` | `GROUP_CONCAT(expression)` | Returns a string with concatenated values that are comma separated and that are non-null from a group. Will return null when there are non-null values. | -| `MAX` | `SELECT MAX(column_name) FROM database.table WHERE condition` | Returns largest value in a specified column. | -| `MIN` | `SELECT MIN(column_name) FROM database.table WHERE condition` | Returns smallest value in a specified column. | -| `SUM` | `SUM(column_name)` | Returns the sum of the numeric values provided. | -| `ARRAY`\* | `ARRAY(expression)` | Returns a list of data as a field. | -| `DISTINCT_ARRAY`\* | `DISTINCT_ARRAY(expression)` | When placed around a standard `ARRAY()` function, returns a distinct (deduplicated) results set. | - -\*For more information on `ARRAY()` and `DISTINCT_ARRAY()` see [this blog](https://www.harperdb.io/post/sql-queries-to-complex-objects). - -### Conversion - -| Keyword | Syntax | Description | -| --------- | ----------------------------------------------- | ---------------------------------------------------------------------- | -| `CAST` | `CAST(expression AS datatype(length))` | Converts a value to a specified datatype. | -| `CONVERT` | `CONVERT(data_type(length), expression, style)` | Converts a value from one datatype to a different, specified datatype. | - -### Date & Time - -| Keyword | Syntax | Description | -| ------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `CURRENT_DATE` | `CURRENT_DATE()` | Returns the current date in UTC in "YYYY-MM-DD" String format. | -| `CURRENT_TIME` | `CURRENT_TIME()` | Returns the current time in UTC in "HH:mm:ss.SSS" string format. | -| `CURRENT_TIMESTAMP` | `CURRENT_TIMESTAMP` | Referencing this variable will evaluate as the current Unix Timestamp in milliseconds. For more information, go here. | -| `DATE` | `DATE([date_string])` | Formats and returns the date string argument in UTC in 'YYYY-MM-DDTHH:mm:ss.SSSZZ' string format. If a date string is not provided, the function will return the current UTC date/time value in the return format defined above. For more information, go here. | -| `DATE_ADD` | `DATE_ADD(date, value, interval)` | Adds the defined amount of time to the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted interval values: Either string value (key or shorthand) can be passed as the interval argument. For more information, go here. | -| `DATE_DIFF` | `DATE_DIFF(date_1, date_2[, interval])` | Returns the difference between the two date values passed based on the interval as a Number. If an interval is not provided, the function will return the difference value in milliseconds. For more information, go here. | -| `DATE_FORMAT` | `DATE_FORMAT(date, format)` | Formats and returns a date value in the String format provided. Find more details on accepted format values in the moment.js docs. For more information, go here. | -| `DATE_SUB` | `DATE_SUB(date, format)` | Subtracts the defined amount of time from the date provided in UTC and returns the resulting Unix Timestamp in milliseconds. Accepted date_sub interval values- Either string value (key or shorthand) can be passed as the interval argument. For more information, go here. | -| `DAY` | `DAY(date)` | Return the day of the month for the given date. | -| `DAYOFWEEK` | `DAYOFWEEK(date)` | Returns the numeric value of the weekday of the date given("YYYY-MM-DD").NOTE: 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, and 6=Saturday. | -| `EXTRACT` | `EXTRACT(date, date_part)` | Extracts and returns the date_part requested as a String value. Accepted date_part values below show value returned for date = "2020-03-26T15:13:02.041+000" For more information, go here. | -| `GETDATE` | `GETDATE()` | Returns the current Unix Timestamp in milliseconds. | -| `GET_SERVER_TIME` | `GET_SERVER_TIME()` | Returns the current date/time value based on the server's timezone in `YYYY-MM-DDTHH:mm:ss.SSSZZ` String format. | -| `OFFSET_UTC` | `OFFSET_UTC(date, offset)` | Returns the UTC date time value with the offset provided included in the return String value formatted as `YYYY-MM-DDTHH:mm:ss.SSSZZ`. The offset argument will be added as minutes unless the value is less than 16 and greater than -16, in which case it will be treated as hours. | -| `NOW` | `NOW()` | Returns the current Unix Timestamp in milliseconds. | -| `HOUR` | `HOUR(datetime)` | Returns the hour part of a given date in range of 0 to 838. | -| `MINUTE` | `MINUTE(datetime)` | Returns the minute part of a time/datetime in range of 0 to 59. | -| `MONTH` | `MONTH(date)` | Returns month part for a specified date in range of 1 to 12. | -| `SECOND` | `SECOND(datetime)` | Returns the seconds part of a time/datetime in range of 0 to 59. | -| `YEAR` | `YEAR(date)` | Returns the year part for a specified date. | - -### Logical - -| Keyword | Syntax | Description | -| -------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------ | -| `IF` | `IF(condition, value_if_true, value_if_false)` | Returns a value if the condition is true, or another value if the condition is false. | -| `IIF` | `IIF(condition, value_if_true, value_if_false)` | Returns a value if the condition is true, or another value if the condition is false. | -| `IFNULL` | `IFNULL(expression, alt_value)` | Returns a specified value if the expression is null. | -| `NULLIF` | `NULLIF(expression_1, expression_2)` | Returns null if expression_1 is equal to expression_2, if not equal, returns expression_1. | - -### Mathematical - -| Keyword | Syntax | Description | -| -------- | ------------------------------- | --------------------------------------------------------------------------------------------------- | -| `ABS` | `ABS(expression)` | Returns the absolute value of a given numeric expression. | -| `CEIL` | `CEIL(number)` | Returns integer ceiling, the smallest integer value that is bigger than or equal to a given number. | -| `EXP` | `EXP(number)` | Returns e to the power of a specified number. | -| `FLOOR` | `FLOOR(number)` | Returns the largest integer value that is smaller than, or equal to, a given number. | -| `RANDOM` | `RANDOM(seed)` | Returns a pseudo random number. | -| `ROUND` | `ROUND(number, decimal_places)` | Rounds a given number to a specified number of decimal places. | -| `SQRT` | `SQRT(expression)` | Returns the square root of an expression. | - -### String - -| Keyword | Syntax | Description | -| ------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `CONCAT` | `CONCAT(string_1, string_2, ...., string_n)` | Concatenates, or joins, two or more strings together, resulting in a single string. | -| `CONCAT_WS` | `CONCAT_WS(separator, string_1, string_2, ...., string_n)` | Concatenates, or joins, two or more strings together with a separator, resulting in a single string. | -| `INSTR` | `INSTR(string_1, string_2)` | Returns the first position, as an integer, of string_2 within string_1. | -| `LEN` | `LEN(string)` | Returns the length of a string. | -| `LOWER` | `LOWER(string)` | Converts a string to lower-case. | -| `REGEXP` | `SELECT column_name FROM database.table WHERE column_name REGEXP pattern` | Searches column for matching string against a given regular expression pattern, provided as a string, and returns all matches. If no matches are found, it returns null. | -| `REGEXP_LIKE` | `SELECT column_name FROM database.table WHERE REGEXP_LIKE(column_name, pattern)` | Searches column for matching string against a given regular expression pattern, provided as a string, and returns all matches. If no matches are found, it returns null. | -| `REPLACE` | `REPLACE(string, old_string, new_string)` | Replaces all instances of old_string within new_string, with string. | -| `SUBSTRING` | `SUBSTRING(string, string_position, length_of_substring)` | Extracts a specified amount of characters from a string. | -| `TRIM` | `TRIM([character(s) FROM] string)` | Removes leading and trailing spaces, or specified character(s), from a string. | -| `UPPER` | `UPPER(string)` | Converts a string to upper-case. | - -## Operators - -### Logical Operators - -| Keyword | Syntax | Description | -| --------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | -| `BETWEEN` | `SELECT column_name(s) FROM database.table WHERE column_name BETWEEN value_1 AND value_2` | (inclusive) Returns values(numbers, text, or dates) within a given range. | -| `IN` | `SELECT column_name(s) FROM database.table WHERE column_name IN(value(s))` | Used to specify multiple values in a WHERE clause. | -| `LIKE` | `SELECT column_name(s) FROM database.table WHERE column_n LIKE pattern` | Searches for a specified pattern within a WHERE clause. | - -## Queries - -### General - -| Keyword | Syntax | Description | -| ---------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | -| `DISTINCT` | `SELECT DISTINCT column_name(s) FROM database.table` | Returns only unique values, eliminating duplicate records. | -| `FROM` | `FROM database.table` | Used to list the database(s), table(s), and any joins required for a SQL statement. | -| `GROUP BY` | `SELECT column_name(s) FROM database.table WHERE condition GROUP BY column_name(s) ORDER BY column_name(s)` | Groups rows that have the same values into summary rows. | -| `HAVING` | `SELECT column_name(s) FROM database.table WHERE condition GROUP BY column_name(s) HAVING condition ORDER BY column_name(s)` | Filters data based on a group or aggregate function. | -| `SELECT` | `SELECT column_name(s) FROM database.table` | Selects data from table. | -| `WHERE` | `SELECT column_name(s) FROM database.table WHERE condition` | Extracts records based on a defined condition. | - -### Joins - -| Keyword | Syntax | Description | -| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `CROSS JOIN` | `SELECT column_name(s) FROM database.table_1 CROSS JOIN database.table_2` | Returns a paired combination of each row from `table_1` with row from `table_2`. Note: CROSS JOIN can return very large result sets and is generally considered bad practice. | -| `FULL OUTER` | `SELECT column_name(s) FROM database.table_1 FULL OUTER JOIN database.table_2 ON table_1.column_name = table_2.column_name WHERE condition` | Returns all records when there is a match in either `table_1` (left table) or `table_2` (right table). | -| `[INNER] JOIN` | `SELECT column_name(s) FROM database.table_1 INNER JOIN database.table_2 ON table_1.column_name = table_2.column_name` | Return only matching records from `table_1` (left table) and `table_2` (right table). The INNER keyword is optional and does not affect the result. | -| `LEFT [OUTER] JOIN` | `SELECT column_name(s) FROM database.table_1 LEFT OUTER JOIN database.table_2 ON table_1.column_name = table_2.column_name` | Return all records from `table_1` (left table) and matching data from `table_2` (right table). The OUTER keyword is optional and does not affect the result. | -| `RIGHT [OUTER] JOIN` | `SELECT column_name(s) FROM database.table_1 RIGHT OUTER JOIN database.table_2 ON table_1.column_name = table_2.column_name` | Return all records from `table_2` (right table) and matching data from `table_1` (left table). The OUTER keyword is optional and does not affect the result. | - -### Predicates - -| Keyword | Syntax | Description | -| ------------- | ------------------------------------------------------------------------- | -------------------------- | -| `IS NOT NULL` | `SELECT column_name(s) FROM database.table WHERE column_name IS NOT NULL` | Tests for non-null values. | -| `IS NULL` | `SELECT column_name(s) FROM database.table WHERE column_name IS NULL` | Tests for null values. | - -### Statements - -| Keyword | Syntax | Description | -| -------- | ---------------------------------------------------------------------------------------- | ----------------------------------- | -| `DELETE` | `DELETE FROM database.table WHERE condition` | Deletes existing data from a table. | -| `INSERT` | `INSERT INTO database.table(column_name(s)) VALUES(value(s))` | Inserts new records into a table. | -| `UPDATE` | `UPDATE database.table SET column_1 = value_1, column_2 = value_2, .... WHERE condition` | Alters existing records in a table. | diff --git a/docs/developers/sql-guide/index.md b/docs/developers/sql-guide/index.md deleted file mode 100644 index 52f245ab..00000000 --- a/docs/developers/sql-guide/index.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: SQL Guide ---- - -# SQL Guide - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -## Harper SQL Guide - -The purpose of this guide is to describe the available functionality of Harper as it relates to supported SQL functionality. The SQL parser is still actively being developed, many SQL features may not be optimized or utilize indexes. This document will be updated as more features and functionality becomes available. Generally, the REST interface provides a more stable, secure, and performant interface for data interaction, but the SQL functionality can be useful for administrative ad-hoc querying, and utilizing existing SQL statements. **A high-level view of supported features can be found** [**here**](sql-guide/features-matrix)**.** - -Harper adheres to the concept of database & tables. This allows developers to isolate table structures from each other all within one database. - -## Select - -Harper has robust SELECT support, from simple queries all the way to complex joins with multi-conditions, aggregates, grouping & ordering. - -All results are returned as JSON object arrays. - -Query for all records and attributes in the dev.dog table: - -``` -SELECT * FROM dev.dog -``` - -Query specific columns from all rows in the dev.dog table: - -``` -SELECT id, dog_name, age FROM dev.dog -``` - -Query for all records and attributes in the dev.dog table ORDERED BY age in ASC order: - -``` -SELECT * FROM dev.dog ORDER BY age -``` - -_The ORDER BY keyword sorts in ascending order by default. To sort in descending order, use the DESC keyword._ - -## Insert - -Harper supports inserting 1 to n records into a table. The primary key must be unique (not used by any other record). If no primary key is provided, it will be assigned an auto-generated UUID. Harper does not support selecting from one table to insert into another at this time. - -``` -INSERT INTO dev.dog (id, dog_name, age, breed_id) - VALUES(1, 'Penny', 5, 347), (2, 'Kato', 4, 347) -``` - -## Update - -Harper supports updating existing table row(s) via UPDATE statements. Multiple conditions can be applied to filter the row(s) to update. At this time selecting from one table to update another is not supported. - -``` -UPDATE dev.dog - SET owner_name = 'Kyle' - WHERE id IN (1, 2) -``` - -## Delete - -Harper supports deleting records from a table with condition support. - -``` -DELETE FROM dev.dog - WHERE age < 4 -``` - -## Joins - -Harper allows developers to join any number of tables and currently supports the following join types: - -- INNER JOIN LEFT -- INNER JOIN LEFT -- OUTER JOIN - -Here’s a basic example joining two tables from our Get Started example- joining a dogs table with a breeds table: - -``` -SELECT d.id, d.dog_name, d.owner_name, b.name, b.section - FROM dev.dog AS d - INNER JOIN dev.breed AS b ON d.breed_id = b.id - WHERE d.owner_name IN ('Kyle', 'Zach', 'Stephen') - AND b.section = 'Mutt' - ORDER BY d.dog_name -``` diff --git a/docs/developers/sql-guide/json-search.md b/docs/developers/sql-guide/json-search.md deleted file mode 100644 index c4bcd1c8..00000000 --- a/docs/developers/sql-guide/json-search.md +++ /dev/null @@ -1,177 +0,0 @@ ---- -title: SQL JSON Search ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# SQL JSON Search - -Harper automatically indexes all top level attributes in a row / object written to a table. However, any attributes which hold JSON data do not have their nested attributes indexed. In order to make searching and/or transforming these JSON documents easy, Harper offers a special SQL function called SEARCH_JSON. The SEARCH_JSON function works in SELECT & WHERE clauses allowing queries to perform powerful filtering on any element of your JSON by implementing the [JSONata library](https://docs.jsonata.org/overview.html) into our SQL engine. - -## Syntax - -`SEARCH_JSON(expression, attribute)` - -Executes the supplied string _expression_ against data of the defined top level _attribute_ for each row. The expression both filters and defines output from the JSON document. - -### Example 1 - -#### Search a string array - -Here are two records in the database: - -```json -[ - { - "id": 1, - "name": ["Harper", "Penny"] - }, - { - "id": 2, - "name": ["Penny"] - } -] -``` - -Here is a simple query that gets any record with "Harper" found in the name. - -``` -SELECT * -FROM dev.dog -WHERE search_json('"Harper" in *', name) -``` - -### Example 2 - -The purpose of this query is to give us every movie where at least two of our favorite actors from Marvel films have acted together. The results will return the movie title, the overview, release date and an object array of the actor’s name and their character name in the movie. - -Both function calls evaluate the credits.cast attribute, this attribute is an object array of every cast member in a movie. - -``` -SELECT m.title, - m.overview, - m.release_date, - SEARCH_JSON($[name in ["Robert Downey Jr.", "Chris Evans", "Scarlett Johansson", "Mark Ruffalo", "Chris Hemsworth", "Jeremy Renner", "Clark Gregg", "Samuel L. Jackson", "Gwyneth Paltrow", "Don Cheadle"]].{"actor": name, "character": character}, c.`cast`) AS characters -FROM movies.credits c - INNER JOIN movies.movie m - ON c.movie_id = m.id -WHERE SEARCH_JSON($count($[name in ["Robert Downey Jr.", "Chris Evans", "Scarlett Johansson", "Mark Ruffalo", "Chris Hemsworth", "Jeremy Renner", "Clark Gregg", "Samuel L. Jackson", "Gwyneth Paltrow", "Don Cheadle"]]), c.`cast`) >= 2 -``` - -A sample of this data from the movie The Avengers looks like - -```json -[ - { - "cast_id": 46, - "character": "Tony Stark / Iron Man", - "credit_id": "52fe4495c3a368484e02b251", - "gender": "male", - "id": 3223, - "name": "Robert Downey Jr.", - "order": 0 - }, - { - "cast_id": 2, - "character": "Steve Rogers / Captain America", - "credit_id": "52fe4495c3a368484e02b19b", - "gender": "male", - "id": 16828, - "name": "Chris Evans", - "order": 1 - }, - { - "cast_id": 307, - "character": "Bruce Banner / The Hulk", - "credit_id": "5e85e8083344c60015411cfa", - "gender": "male", - "id": 103, - "name": "Mark Ruffalo", - "order": 2 - } -] -``` - -Let’s break down the SEARCH_JSON function call in the SELECT: - -``` -SEARCH_JSON( - $[name in [ - "Robert Downey Jr.", - "Chris Evans", - "Scarlett Johansson", - "Mark Ruffalo", - "Chris Hemsworth", - "Jeremy Renner", - "Clark Gregg", - "Samuel L. Jackson", - "Gwyneth Paltrow", - "Don Cheadle" - ]].{ - "actor": name, - "character": character - }, - c.`cast` -) -``` - -The first argument passed to SEARCH_JSON is the expression to execute against the second argument which is the cast attribute on the credits table. This expression will execute for every row. Looking into the expression it starts with "$[…]" this tells the expression to iterate all elements of the cast array. - -Then the expression tells the function to only return entries where the name attribute matches any of the actors defined in the array: - -``` -name in ["Robert Downey Jr.", "Chris Evans", "Scarlett Johansson", "Mark Ruffalo", "Chris Hemsworth", "Jeremy Renner", "Clark Gregg", "Samuel L. Jackson", "Gwyneth Paltrow", "Don Cheadle"] -``` - -So far, we’ve iterated the array and filtered out rows, but we also want the results formatted in a specific way, so we’ve chained an expression on our filter with: `{"actor": name, "character": character}`. This tells the function to create a specific object for each matching entry. - -**Sample Result** - -```json -[ - { - "actor": "Robert Downey Jr.", - "character": "Tony Stark / Iron Man" - }, - { - "actor": "Chris Evans", - "character": "Steve Rogers / Captain America" - }, - { - "actor": "Mark Ruffalo", - "character": "Bruce Banner / The Hulk" - } -] -``` - -Just having the SEARCH_JSON function in our SELECT is powerful, but given our criteria it would still return every other movie that doesn’t have our matching actors, in order to filter out the movies we do not want we also use SEARCH_JSON in the WHERE clause. - -This function call in the WHERE clause is similar, but we don’t need to perform the same transformation as occurred in the SELECT: - -``` -SEARCH_JSON( - $count( - $[name in [ - "Robert Downey Jr.", - "Chris Evans", - "Scarlett Johansson", - "Mark Ruffalo", - "Chris Hemsworth", - "Jeremy Renner", - "Clark Gregg", - "Samuel L. Jackson", - "Gwyneth Paltrow", - "Don Cheadle" - ]] - ), - c.`cast` -) >= 2 -``` - -As seen above we execute the same name filter against the cast array, the primary difference is we are wrapping the filtered results in $count(…). As it looks this returns a count of the results back which we then use against our SQL comparator of >= 2. - -To see further SEARCH_JSON examples in action view our Postman Collection that provides a [sample database & data with query examples](../operations-api/advanced-json-sql-examples). - -To learn more about how to build expressions check out the JSONata documentation: [https://docs.jsonata.org/overview](https://docs.jsonata.org/overview) diff --git a/docs/developers/sql-guide/reserved-word.md b/docs/developers/sql-guide/reserved-word.md deleted file mode 100644 index 2cd812ba..00000000 --- a/docs/developers/sql-guide/reserved-word.md +++ /dev/null @@ -1,207 +0,0 @@ ---- -title: Harper SQL Reserved Words ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# Harper SQL Reserved Words - -This is a list of reserved words in the SQL Parser. Use of these words or symbols may result in unexpected behavior or inaccessible tables/attributes. If any of these words must be used, any SQL call referencing a database, table, or attribute must have backticks (`…`) or brackets ([…]) around the variable. - -For Example, for a table called `ASSERT` in the `data` database, a SQL select on that table would look like: - -``` -SELECT * from data.`ASSERT` -``` - -Alternatively: - -``` -SELECT * from data.[ASSERT] -``` - -### RESERVED WORD LIST - -- ABSOLUTE -- ACTION -- ADD -- AGGR -- ALL -- ALTER -- AND -- ANTI -- ANY -- APPLY -- ARRAY -- AS -- ASSERT -- ASC -- ATTACH -- AUTOINCREMENT -- AUTO_INCREMENT -- AVG -- BEGIN -- BETWEEN -- BREAK -- BY -- CALL -- CASE -- CAST -- CHECK -- CLASS -- CLOSE -- COLLATE -- COLUMN -- COLUMNS -- COMMIT -- CONSTRAINT -- CONTENT -- CONTINUE -- CONVERT -- CORRESPONDING -- COUNT -- CREATE -- CROSS -- CUBE -- CURRENT_TIMESTAMP -- CURSOR -- DATABASE -- DECLARE -- DEFAULT -- DELETE -- DELETED -- DESC -- DETACH -- DISTINCT -- DOUBLEPRECISION -- DROP -- ECHO -- EDGE -- END -- ENUM -- ELSE -- EXCEPT -- EXISTS -- EXPLAIN -- FALSE -- FETCH -- FIRST -- FOREIGN -- FROM -- GO -- GRAPH -- GROUP -- GROUPING -- HAVING -- HDB_HASH -- HELP -- IF -- IDENTITY -- IS -- IN -- INDEX -- INNER -- INSERT -- INSERTED -- INTERSECT -- INTO -- JOIN -- KEY -- LAST -- LET -- LEFT -- LIKE -- LIMIT -- LOOP -- MATCHED -- MATRIX -- MAX -- MERGE -- MIN -- MINUS -- MODIFY -- NATURAL -- NEXT -- NEW -- NOCASE -- NO -- NOT -- NULL -- OFF -- ON -- ONLY -- OFFSET -- OPEN -- OPTION -- OR -- ORDER -- OUTER -- OVER -- PATH -- PARTITION -- PERCENT -- PLAN -- PRIMARY -- PRINT -- PRIOR -- QUERY -- READ -- RECORDSET -- REDUCE -- REFERENCES -- RELATIVE -- REPLACE -- REMOVE -- RENAME -- REQUIRE -- RESTORE -- RETURN -- RETURNS -- RIGHT -- ROLLBACK -- ROLLUP -- ROW -- SCHEMA -- SCHEMAS -- SEARCH -- SELECT -- SEMI -- SET -- SETS -- SHOW -- SOME -- SOURCE -- STRATEGY -- STORE -- SYSTEM -- SUM -- TABLE -- TABLES -- TARGET -- TEMP -- TEMPORARY -- TEXTSTRING -- THEN -- TIMEOUT -- TO -- TOP -- TRAN -- TRANSACTION -- TRIGGER -- TRUE -- TRUNCATE -- UNION -- UNIQUE -- UPDATE -- USE -- USING -- VALUE -- VERTEX -- VIEW -- WHEN -- WHERE -- WHILE -- WITH -- WORK diff --git a/docs/developers/sql-guide/sql-geospatial-functions.md b/docs/developers/sql-guide/sql-geospatial-functions.md deleted file mode 100644 index f0c571da..00000000 --- a/docs/developers/sql-guide/sql-geospatial-functions.md +++ /dev/null @@ -1,419 +0,0 @@ ---- -title: SQL Geospatial Functions ---- - -:::warning -Harper encourages developers to utilize other querying tools over SQL for performance purposes. Harper SQL is intended for data investigation purposes and uses cases where performance is not a priority. SQL optimizations are on our roadmap for the future. -::: - -# SQL Geospatial Functions - -Harper geospatial features require data to be stored in a single column using the [GeoJSON standard](https://geojson.org/), a standard commonly used in geospatial technologies. Geospatial functions are available to be used in SQL statements. - -If you are new to GeoJSON you should check out the full specification here: https://geojson.org/. There are a few important things to point out before getting started. - -1. All GeoJSON coordinates are stored in `[longitude, latitude]` format. -1. Coordinates or GeoJSON geometries must be passed as string when written directly in a SQL statement. -1. Note if you are using Postman for you testing. Due to limitations in the Postman client, you will need to escape quotes in your strings and your SQL will need to be passed on a single line. - -In the examples contained in the left-hand navigation, database and table names may change, but all GeoJSON data will be stored in a column named geo_data. - -# geoArea - -The geoArea() function returns the area of one or more features in square meters. - -### Syntax - -geoArea(_geoJSON_) - -### Parameters - -| Parameter | Description | -| --------- | ------------------------------- | -| geoJSON | Required. One or more features. | - -#### Example 1 - -Calculate the area, in square meters, of a manually passed GeoJSON polygon. - -``` -SELECT geoArea('{ - "type":"Feature", - "geometry":{ - "type":"Polygon", - "coordinates":[[ - [0,0], - [0.123456,0], - [0.123456,0.123456], - [0,0.123456] - ]] - } -}') -``` - -#### Example 2 - -Find all records that have an area less than 1 square mile (or 2589988 square meters). - -``` -SELECT * FROM dev.locations -WHERE geoArea(geo_data) < 2589988 -``` - -# geoLength - -Takes a GeoJSON and measures its length in the specified units (default is kilometers). - -## Syntax - -geoLength(_geoJSON_[_, units_]) - -## Parameters - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------------------------------------------- | -| geoJSON | Required. GeoJSON to measure. | -| units | Optional. Specified as a string. Options are ‘degrees’, ‘radians’, ‘miles’, or ‘kilometers’. Default is ‘kilometers’. | - -### Example 1 - -Calculate the length, in kilometers, of a manually passed GeoJSON linestring. - -``` -SELECT geoLength('{ - "type": "Feature", - "geometry": { - "type": "LineString", - "coordinates": [ - [-104.97963309288025,39.76163265441438], - [-104.9823260307312,39.76365323407955], - [-104.99193906784058,39.75616442110704] - ] - } -}') -``` - -### Example 2 - -Find all data plus the calculated length in miles of the GeoJSON, restrict the response to only lengths less than 5 miles, and return the data in order of lengths smallest to largest. - -``` -SELECT *, geoLength(geo_data, 'miles') as length -FROM dev.locations -WHERE geoLength(geo_data, 'miles') < 5 -ORDER BY length ASC -``` - -# geoDifference - -Returns a new polygon with the difference of the second polygon clipped from the first polygon. - -## Syntax - -geoDifference(_polygon1, polygon2_) - -## Parameters - -| Parameter | Description | -| --------- | -------------------------------------------------------------------------- | -| polygon1 | Required. Polygon or MultiPolygon GeoJSON feature. | -| polygon2 | Required. Polygon or MultiPolygon GeoJSON feature to remove from polygon1. | - -### Example - -Return a GeoJSON Polygon that removes City Park (_polygon2_) from Colorado (_polygon1_). - -``` -SELECT geoDifference('{ - "type": "Feature", - "properties": { - "name":"Colorado" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-109.072265625,37.00255267215955], - [-102.01904296874999,37.00255267215955], - [-102.01904296874999,41.0130657870063], - [-109.072265625,41.0130657870063], - [-109.072265625,37.00255267215955] - ]] - } - }', - '{ - "type": "Feature", - "properties": { - "name":"City Park" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-104.95973110198975,39.7543828214657], - [-104.95955944061278,39.744781185675386], - [-104.95904445648193,39.74422022399989], - [-104.95835781097412,39.74402223643582], - [-104.94097709655762,39.74392324244047], - [-104.9408483505249,39.75434982844515], - [-104.95973110198975,39.7543828214657] - ]] - } - }' -) -``` - -# geoDistance - -Calculates the distance between two points in units (default is kilometers). - -## Syntax - -geoDistance(_point1, point2_[_, units_]) - -## Parameters - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------------------------------------------- | -| point1 | Required. GeoJSON Point specifying the origin. | -| point2 | Required. GeoJSON Point specifying the destination. | -| units | Optional. Specified as a string. Options are ‘degrees’, ‘radians’, ‘miles’, or ‘kilometers’. Default is ‘kilometers’. | - -### Example 1 - -Calculate the distance, in miles, between Harper’s headquarters and the Washington Monument. - -``` -SELECT geoDistance('[-104.979127,39.761563]', '[-77.035248,38.889475]', 'miles') -``` - -### Example 2 - -Find all locations that are within 40 kilometers of a given point, return that distance in miles, and sort by distance in an ascending order. - -``` -SELECT *, geoDistance('[-104.979127,39.761563]', geo_data, 'miles') as distance -FROM dev.locations -WHERE geoDistance('[-104.979127,39.761563]', geo_data, 'kilometers') < 40 -ORDER BY distance ASC -``` - -# geoNear - -Determines if point1 and point2 are within a specified distance from each other, default units are kilometers. Returns a Boolean. - -## Syntax - -geoNear(_point1, point2, distance_[_, units_]) - -## Parameters - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------------------------------------------- | -| point1 | Required. GeoJSON Point specifying the origin. | -| point2 | Required. GeoJSON Point specifying the destination. | -| distance | Required. The maximum distance in units as an integer or decimal. | -| units | Optional. Specified as a string. Options are ‘degrees’, ‘radians’, ‘miles’, or ‘kilometers’. Default is ‘kilometers’. | - -### Example 1 - -Return all locations within 50 miles of a given point. - -``` -SELECT * -FROM dev.locations -WHERE geoNear('[-104.979127,39.761563]', geo_data, 50, 'miles') -``` - -### Example 2 - -Return all locations within 2 degrees of the earth of a given point. (Each degree lat/long is about 69 miles [111 kilometers]). Return all data and the distance in miles, sorted by ascending distance. - -``` -SELECT *, geoDistance('[-104.979127,39.761563]', geo_data, 'miles') as distance -FROM dev.locations -WHERE geoNear('[-104.979127,39.761563]', geo_data, 2, 'degrees') -ORDER BY distance ASC -``` - -# geoContains - -Determines if geo2 is completely contained by geo1. Returns a Boolean. - -## Syntax - -geoContains(_geo1, geo2_) - -## Parameters - -| Parameter | Description | -| --------- | --------------------------------------------------------------------------------- | -| geo1 | Required. Polygon or MultiPolygon GeoJSON feature. | -| geo2 | Required. Polygon or MultiPolygon GeoJSON feature tested to be contained by geo1. | - -### Example 1 - -Return all locations within the state of Colorado (passed as a GeoJSON string). - -``` -SELECT * -FROM dev.locations -WHERE geoContains('{ - "type": "Feature", - "properties": { - "name":"Colorado" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-109.072265625,37.00255267], - [-102.01904296874999,37.00255267], - [-102.01904296874999,41.01306579], - [-109.072265625,41.01306579], - [-109.072265625,37.00255267] - ]] - } -}', geo_data) -``` - -### Example 2 - -Return all locations which contain Harper Headquarters. - -``` -SELECT * -FROM dev.locations -WHERE geoContains(geo_data, '{ - "type": "Feature", - "properties": { - "name": "Harper Headquarters" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-104.98060941696167,39.760704817357905], - [-104.98053967952728,39.76065120861263], - [-104.98055577278137,39.760642961109674], - [-104.98037070035934,39.76049450588716], - [-104.9802714586258,39.76056254790385], - [-104.9805235862732,39.76076461167841], - [-104.98060941696167,39.760704817357905] - ]] - } -}') -``` - -# geoEqual - -Determines if two GeoJSON features are the same type and have identical X,Y coordinate values. For more information see https://developers.arcgis.com/documentation/spatial-references/. Returns a Boolean. - -## Syntax - -geoEqual(_geo1_, _geo2_) - -## Parameters - -| Parameter | Description | -| --------- | -------------------------------------- | -| geo1 | Required. GeoJSON geometry or feature. | -| geo2 | Required. GeoJSON geometry or feature. | - -### Example - -Find Harper Headquarters within all locations within the database. - -``` -SELECT * -FROM dev.locations -WHERE geoEqual(geo_data, '{ - "type": "Feature", - "properties": { - "name": "Harper Headquarters" - }, - "geometry": { - "type": "Polygon", - "coordinates": [[ - [-104.98060941696167,39.760704817357905], - [-104.98053967952728,39.76065120861263], - [-104.98055577278137,39.760642961109674], - [-104.98037070035934,39.76049450588716], - [-104.9802714586258,39.76056254790385], - [-104.9805235862732,39.76076461167841], - [-104.98060941696167,39.760704817357905] - ]] - } -}') -``` - -# geoCrosses - -Determines if the geometries cross over each other. Returns boolean. - -## Syntax - -geoCrosses(_geo1, geo2_) - -## Parameters - -| Parameter | Description | -| --------- | -------------------------------------- | -| geo1 | Required. GeoJSON geometry or feature. | -| geo2 | Required. GeoJSON geometry or feature. | - -### Example - -Find all locations that cross over a highway. - -``` -SELECT * -FROM dev.locations -WHERE geoCrosses( - geo_data, - '{ - "type": "Feature", - "properties": { - "name": "Highway I-25" - }, - "geometry": { - "type": "LineString", - "coordinates": [ - [-104.9139404296875,41.00477542222947], - [-105.0238037109375,39.715638134796336], - [-104.853515625,39.53370327008705], - [-104.853515625,38.81403111409755], - [-104.61181640625,38.39764411353178], - [-104.8974609375,37.68382032669382], - [-104.501953125,37.00255267215955] - ] - } - }' -) -``` - -# geoConvert - -Converts a series of coordinates into a GeoJSON of the specified type. - -## Syntax - -geoConvert(_coordinates, geo_type_[, _properties_]) - -## Parameters - -| Parameter | Description | -| ----------- | ---------------------------------------------------------------------------------------------------------------------------------- | -| coordinates | Required. One or more coordinates | -| geo_type | Required. GeoJSON geometry type. Options are ‘point’, ‘lineString’, ‘multiLineString’, ‘multiPoint’, ‘multiPolygon’, and ‘polygon’ | -| properties | Optional. Escaped JSON array with properties to be added to the GeoJSON output. | - -### Example - -Convert a given coordinate into a GeoJSON point with specified properties. - -``` -SELECT geoConvert( - '[-104.979127,39.761563]', - 'point', - '{ - "name": "Harper Headquarters" - }' -) -``` From a89284685f55a3dece0fe78592abb17318f625c9 Mon Sep 17 00:00:00 2001 From: nenharper Date: Thu, 25 Sep 2025 11:59:15 -0500 Subject: [PATCH 3/4] Redirects --- redirects.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redirects.ts b/redirects.ts index 8c311736..3dbe129c 100644 --- a/redirects.ts +++ b/redirects.ts @@ -149,7 +149,7 @@ function generateDocsRedirects(basePath: string): RedirectRule[] { }, // SQL Guide - { from: withBase('/sql-guide'), to: withBase('/developers/sql-guide/') }, + { from: withBase('/sql-guide'), to: withBase('/') }, // CLI { from: withBase('/harperdb-cli'), to: withBase('/deployments/harper-cli') }, From 64ec32b45a38802dc3761835f26997c69130da2c Mon Sep 17 00:00:00 2001 From: nenharper Date: Thu, 25 Sep 2025 16:58:00 -0500 Subject: [PATCH 4/4] Add all redirects --- redirects.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/redirects.ts b/redirects.ts index 3dbe129c..4d67325b 100644 --- a/redirects.ts +++ b/redirects.ts @@ -150,6 +150,13 @@ function generateDocsRedirects(basePath: string): RedirectRule[] { // SQL Guide { from: withBase('/sql-guide'), to: withBase('/') }, + { from: withBase('/developers/sql-guide'), to: withBase('/') }, + { from: withBase('/developers/sql-guide/date-functions'), to: withBase('/') }, + { from: withBase('/developers/sql-guide/features-matrix'), to: withBase('/') }, + { from: withBase('/developers/sql-guide/functions'), to: withBase('/') }, + { from: withBase('/developers/sql-guide/json-search'), to: withBase('/') }, + { from: withBase('/developers/sql-guide/reserved-word'), to: withBase('/') }, + { from: withBase('/developers/sql-guide/sql-geospatial-functions'), to: withBase('/') }, // CLI { from: withBase('/harperdb-cli'), to: withBase('/deployments/harper-cli') },