-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Join and Lookup IT on OpenSearch Table (#1025)
Signed-off-by: Peng Huo <penghuo@gmail.com>
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 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
50 changes: 50 additions & 0 deletions
50
...src/integration/scala/org/apache/spark/opensearch/table/OpenSearchTableQueryITSuite.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,50 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.apache.spark.opensearch.table | ||
|
||
import org.opensearch.flint.spark.ppl.FlintPPLSuite | ||
|
||
import org.apache.spark.sql.Row | ||
|
||
/** | ||
* Test queries on OpenSearch Table | ||
*/ | ||
class OpenSearchTableQueryITSuite extends OpenSearchCatalogSuite with FlintPPLSuite { | ||
test("SQL Join two indices") { | ||
val indexName1 = "t0001" | ||
val indexName2 = "t0002" | ||
withIndexName(indexName1) { | ||
withIndexName(indexName2) { | ||
simpleIndex(indexName1) | ||
simpleIndex(indexName2) | ||
val df = spark.sql(s""" | ||
SELECT t1.accountId, t2.eventName, t2.eventSource | ||
FROM ${catalogName}.default.$indexName1 as t1 JOIN ${catalogName}.default.$indexName2 as t2 ON | ||
t1.accountId == t2.accountId""") | ||
|
||
checkAnswer(df, Row("123", "event", "source")) | ||
} | ||
} | ||
} | ||
|
||
test("PPL Lookup") { | ||
val indexName1 = "t0001" | ||
val indexName2 = "t0002" | ||
val factTbl = s"${catalogName}.default.$indexName1" | ||
val lookupTbl = s"${catalogName}.default.$indexName2" | ||
withIndexName(indexName1) { | ||
withIndexName(indexName2) { | ||
simpleIndex(indexName1) | ||
simpleIndex(indexName2) | ||
|
||
val df = spark.sql( | ||
s"source = $factTbl | stats count() by accountId " + | ||
s"| LOOKUP $lookupTbl accountId REPLACE eventSource") | ||
checkAnswer(df, Row(1, "123", "source")) | ||
} | ||
} | ||
} | ||
} |