|
| 1 | +.. Licensed to the Apache Software Foundation (ASF) under one or more |
| 2 | + contributor license agreements. See the NOTICE file distributed with |
| 3 | + this work for additional information regarding copyright ownership. |
| 4 | + The ASF licenses this file to You under the Apache License, Version 2.0 |
| 5 | + (the "License"); you may not use this file except in compliance with |
| 6 | + the License. You may obtain a copy of the License at |
| 7 | +
|
| 8 | +.. http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +.. Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | +
|
| 16 | +TPC-DS |
| 17 | +===== |
| 18 | + |
| 19 | +The TPC-DS is a decision support benchmark. It consists of a suite of business oriented ad-hoc queries and concurrent |
| 20 | +data modifications. The queries and the data populating the database have been chosen to have broad industry-wide |
| 21 | +relevance. |
| 22 | + |
| 23 | +.. tip:: |
| 24 | + This article assumes that you have mastered the basic knowledge and operation of `TPC-DS`_. |
| 25 | + For the knowledge about TPC-DS not mentioned in this article, you can obtain it from its `Official Documentation`_. |
| 26 | + |
| 27 | +This connector can be used to test the capabilities and query syntax of Spark without configuring access to an external |
| 28 | +data source. When you query a TPC-DS table, the connector generates the data on the fly using a deterministic algorithm. |
| 29 | + |
| 30 | +Goto `Try Kyuubi`_ to explore TPC-DS data instantly! |
| 31 | + |
| 32 | +TPC-DS Integration |
| 33 | +------------------ |
| 34 | + |
| 35 | +To enable the integration of kyuubi spark sql engine and TPC-DS through |
| 36 | +Apache Spark Datasource V2 and Catalog APIs, you need to: |
| 37 | + |
| 38 | +- Referencing the TPC-DS connector :ref:`dependencies<spark-tpcds-deps>` |
| 39 | +- Setting the spark catalog :ref:`configurations<spark-tpcds-conf>` |
| 40 | + |
| 41 | +.. _spark-tpcds-deps: |
| 42 | + |
| 43 | +Dependencies |
| 44 | +************ |
| 45 | + |
| 46 | +The **classpath** of kyuubi spark sql engine with TPC-DS supported consists of |
| 47 | + |
| 48 | +1. kyuubi-spark-sql-engine-\ |release|\ _2.12.jar, the engine jar deployed with Kyuubi distributions |
| 49 | +2. a copy of spark distribution |
| 50 | +3. kyuubi-spark-connector-tpcds-\ |release|\ _2.12.jar, which can be found in the `Maven Central`_ |
| 51 | + |
| 52 | +In order to make the TPC-DS connector package visible for the runtime classpath of engines, we can use one of these methods: |
| 53 | + |
| 54 | +1. Put the TPC-DS connector package into ``$SPARK_HOME/jars`` directly |
| 55 | +2. Set spark.jars=kyuubi-spark-connector-tpcds-\ |release|\ _2.12.jar |
| 56 | + |
| 57 | +.. _spark-tpcds-conf: |
| 58 | + |
| 59 | +Configurations |
| 60 | +************** |
| 61 | + |
| 62 | +To add TPC-DS tables as a catalog, we can set the following configurations in ``$SPARK_HOME/conf/spark-defaults.conf``: |
| 63 | + |
| 64 | +.. code-block:: properties |
| 65 | +
|
| 66 | + # (required) Register a catalog named `tpcds` for the spark engine. |
| 67 | + spark.sql.catalog.tpcds=org.apache.kyuubi.spark.connector.tpcds.TPCDSCatalog |
| 68 | +
|
| 69 | + # (optional) Excluded database list from the catalog, all available databases are: |
| 70 | + # sf0, tiny, sf1, sf10, sf30, sf100, sf300, sf1000, sf3000, sf10000, sf30000, sf100000. |
| 71 | + spark.sql.catalog.tpcds.excludeDatabases=sf10000,sf30000 |
| 72 | +
|
| 73 | + # (optional) When true, use CHAR/VARCHAR, otherwise use STRING. It affects output of the table schema, |
| 74 | + # e.g. `SHOW CREATE TABLE <table>`, `DESC <table>`. |
| 75 | + spark.sql.catalog.tpcds.useAnsiStringType=false |
| 76 | +
|
| 77 | + # (optional) TPCDS changed table schemas in v2.6.0, turn off this option to use old table schemas. |
| 78 | + # See detail at: https://www.tpc.org/tpc_documents_current_versions/pdf/tpc-ds_v3.2.0.pdf |
| 79 | + spark.sql.catalog.tpcds.useTableSchema_2_6=true |
| 80 | +
|
| 81 | + # (optional) Maximum bytes per task, consider reducing it if you want higher parallelism. |
| 82 | + spark.sql.catalog.tpcds.read.maxPartitionBytes=128m |
| 83 | +
|
| 84 | +TPC-DS Operations |
| 85 | +---------------- |
| 86 | + |
| 87 | +Listing databases under `tpcds` catalog. |
| 88 | + |
| 89 | +.. code-block:: sql |
| 90 | +
|
| 91 | + SHOW DATABASES IN tpcds; |
| 92 | +
|
| 93 | +Listing tables under `tpcds.sf1` database. |
| 94 | + |
| 95 | +.. code-block:: sql |
| 96 | +
|
| 97 | + SHOW TABLES IN tpcds.sf1; |
| 98 | +
|
| 99 | +Switch current database to `tpcds.sf1` and run a query against it. |
| 100 | + |
| 101 | +.. code-block:: sql |
| 102 | +
|
| 103 | + USE tpcds.sf1; |
| 104 | + SELECT * FROM orders; |
| 105 | +
|
| 106 | +.. _Official Documentation: https://www.tpc.org/tpcds/ |
| 107 | +.. _Try Kyuubi: https://try.kyuubi.cloud/ |
| 108 | +.. _Maven Central: https://repo1.maven.org/maven2/org/apache/kyuubi/kyuubi-spark-connector-tpcds_2.12/ |
0 commit comments