-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ppl-tablesample-feature
# Conflicts: # docs/ppl-lang/README.md
- Loading branch information
Showing
12 changed files
with
376 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
## PPL Cryptographic Functions | ||
|
||
### `MD5` | ||
|
||
**Description** | ||
|
||
Calculates the MD5 digest and returns the value as a 32 character hex string. | ||
|
||
Usage: `md5('hello')` | ||
|
||
**Argument type:** | ||
- STRING | ||
- Return type: **STRING** | ||
|
||
Example: | ||
|
||
os> source=people | eval `MD5('hello')` = MD5('hello') | fields `MD5('hello')` | ||
fetched rows / total rows = 1/1 | ||
+----------------------------------+ | ||
| MD5('hello') | | ||
|----------------------------------| | ||
| 5d41402abc4b2a76b9719d911017c592 | | ||
+----------------------------------+ | ||
|
||
### `SHA1` | ||
|
||
**Description** | ||
|
||
Returns the hex string result of SHA-1 | ||
|
||
Usage: `sha1('hello')` | ||
|
||
**Argument type:** | ||
- STRING | ||
- Return type: **STRING** | ||
|
||
Example: | ||
|
||
os> source=people | eval `SHA1('hello')` = SHA1('hello') | fields `SHA1('hello')` | ||
fetched rows / total rows = 1/1 | ||
+------------------------------------------+ | ||
| SHA1('hello') | | ||
|------------------------------------------| | ||
| aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d | | ||
+------------------------------------------+ | ||
|
||
### `SHA2` | ||
|
||
**Description** | ||
|
||
Returns the hex string result of SHA-2 family of hash functions (SHA-224, SHA-256, SHA-384, and SHA-512). The numBits indicates the desired bit length of the result, which must have a value of 224, 256, 384, 512 | ||
|
||
Usage: `sha2('hello',256)` | ||
|
||
Usage: `sha2('hello',512)` | ||
|
||
**Argument type:** | ||
- STRING, INTEGER | ||
- Return type: **STRING** | ||
|
||
Example: | ||
|
||
os> source=people | eval `SHA2('hello',256)` = SHA2('hello',256) | fields `SHA2('hello',256)` | ||
fetched rows / total rows = 1/1 | ||
+------------------------------------------------------------------+ | ||
| SHA2('hello',256) | | ||
|------------------------------------------------------------------| | ||
| 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 | | ||
+------------------------------------------------------------------+ | ||
|
||
os> source=people | eval `SHA2('hello',512)` = SHA2('hello',512) | fields `SHA2('hello',512)` | ||
fetched rows / total rows = 1/1 | ||
+----------------------------------------------------------------------------------------------------------------------------------+ | ||
| SHA2('hello',512) | | ||
|----------------------------------------------------------------------------------------------------------------------------------| | ||
| 9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043 | | ||
+----------------------------------------------------------------------------------------------------------------------------------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## Comments | ||
|
||
Comments are not evaluated texts. PPL supports both line comments and block comments. | ||
|
||
### Line Comments | ||
|
||
Line comments begin with two slashes `//` and end with a new line. | ||
|
||
Example:: | ||
|
||
os> source=accounts | top gender // finds most common gender of all the accounts | ||
fetched rows / total rows = 2/2 | ||
+----------+ | ||
| gender | | ||
|----------| | ||
| M | | ||
| F | | ||
+----------+ | ||
|
||
### Block Comments | ||
|
||
Block comments begin with a slash followed by an asterisk `\*` and end with an asterisk followed by a slash `*/`. | ||
|
||
Example:: | ||
|
||
os> source=accounts | dedup 2 gender /* dedup the document with gender field keep 2 duplication */ | fields account_number, gender | ||
fetched rows / total rows = 3/3 | ||
+------------------+----------+ | ||
| account_number | gender | | ||
|------------------+----------| | ||
| 1 | M | | ||
| 6 | M | | ||
| 13 | F | | ||
+------------------+----------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...st/src/integration/scala/org/opensearch/flint/spark/ppl/FlintSparkPPLCommentITSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.flint.spark.ppl | ||
|
||
import org.opensearch.sql.ppl.utils.DataTypeTransformer.seq | ||
|
||
import org.apache.spark.sql.{AnalysisException, QueryTest, Row} | ||
import org.apache.spark.sql.catalyst.analysis.{UnresolvedAttribute, UnresolvedFunction, UnresolvedRelation, UnresolvedStar} | ||
import org.apache.spark.sql.catalyst.expressions.{Alias, And, Ascending, CaseWhen, Descending, EqualTo, GreaterThanOrEqual, LessThan, Literal, SortOrder} | ||
import org.apache.spark.sql.catalyst.plans.logical._ | ||
import org.apache.spark.sql.streaming.StreamTest | ||
|
||
class FlintSparkPPLCommentITSuite | ||
extends QueryTest | ||
with LogicalPlanTestUtils | ||
with FlintPPLSuite | ||
with StreamTest { | ||
|
||
private val testTable = "spark_catalog.default.flint_ppl_test" | ||
|
||
override def beforeAll(): Unit = { | ||
super.beforeAll() | ||
|
||
createPartitionedStateCountryTable(testTable) | ||
} | ||
|
||
protected override def afterEach(): Unit = { | ||
super.afterEach() | ||
spark.streams.active.foreach { job => | ||
job.stop() | ||
job.awaitTermination() | ||
} | ||
} | ||
|
||
test("test line comment") { | ||
val frame = sql(s""" | ||
| /* | ||
| * This is a | ||
| * multiple | ||
| * line block | ||
| * comment | ||
| */ | ||
| source = /* block comment */ $testTable /* block comment */ | ||
| | eval /* | ||
| This is a | ||
| multiple | ||
| line | ||
| block | ||
| comment | ||
| */ col = 1 | ||
| | /* block comment */ fields name, /* block comment */ age | ||
| /* block comment */ | ||
| """.stripMargin) | ||
|
||
val results: Array[Row] = frame.collect() | ||
val expectedResults: Array[Row] = | ||
Array(Row("Jake", 70), Row("Hello", 30), Row("John", 25), Row("Jane", 20)) | ||
implicit val rowOrdering: Ordering[Row] = Ordering.by[Row, String](_.getAs[String](0)) | ||
assert(results.sorted.sameElements(expectedResults.sorted)) | ||
} | ||
|
||
test("test block comment") { | ||
val frame = sql(s""" | ||
| source = $testTable //line comment | ||
| | eval col = 1 // line comment | ||
| | fields name, age // line comment | ||
| /////////line comment | ||
| """.stripMargin) | ||
|
||
val results: Array[Row] = frame.collect() | ||
val expectedResults: Array[Row] = | ||
Array(Row("Jake", 70), Row("Hello", 30), Row("John", 25), Row("Jane", 20)) | ||
implicit val rowOrdering: Ordering[Row] = Ordering.by[Row, String](_.getAs[String](0)) | ||
assert(results.sorted.sameElements(expectedResults.sorted)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.