Skip to content

Commit

Permalink
[KYUUBI #487] Add TPC-DS DDL test cases
Browse files Browse the repository at this point in the history
![yaooqinn](https://badgen.net/badge/Hello/yaooqinn/green) [![Closes #487](https://badgen.net/badge/Preview/Closes%20%23487/blue)](https://github.com/yaooqinn/kyuubi/pull/487) ![735](https://badgen.net/badge/%2B/735/red) ![0](https://badgen.net/badge/-/0/green) ![1](https://badgen.net/badge/commits/1/yellow) ![Target Issue](https://badgen.net/badge/Missing/Target%20Issue/ff0000) [<img width="16" alt="Powered by Pull Request Badge" src="https://user-images.githubusercontent.com/1393946/111216524-d2bb8e00-85d4-11eb-821b-ed4c00989c02.png">](https://pullrequestbadge.com/?utm_medium=github&utm_source=yaooqinn&utm_campaign=badge_info)<!-- PR-BADGE: PLEASE DO NOT REMOVE THIS COMMENT -->

<!--
Thanks for sending a pull request!

Here are some tips for you:
  1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html
  2. If the PR is related to an issue in https://github.com/yaooqinn/kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
  3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
-->

### _Why are the changes needed?_
<!--
Please clarify why the changes are needed. For instance,
  1. If you add a feature, you can talk about the use case of it.
  2. If you fix a bug, you can clarify why it is a bug.
-->

Verifying TPC-DS DDLs, we should cover DML, DQL later, and maybe benchmark tests

### _How was this patch tested?_
- [x] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.readthedocs.io/en/latest/tools/testing.html#running-tests) locally before make a pull request

Closes #487 from yaooqinn/tpcdsddl.

db558ea [Kent Yao] Add TPC-DS DDL test cases

Authored-by: Kent Yao <[email protected]>
Signed-off-by: ulysses-you <[email protected]>
  • Loading branch information
yaooqinn authored and ulysses-you committed Apr 13, 2021
1 parent 4813005 commit 006016d
Show file tree
Hide file tree
Showing 2 changed files with 735 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.kyuubi.operation.tpcds

import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.operation.{JDBCTestUtils, WithKyuubiServer}

class TPCDSDDLSuite extends WithKyuubiServer with JDBCTestUtils with TPCDSHelper {
override protected val conf: KyuubiConf = KyuubiConf()

override protected def jdbcUrl: String = getJdbcUrl

override def format: String = "hive OPTIONS(fileFormat='parquet')"

override def database: String = this.getClass.getSimpleName

override def beforeAll(): Unit = {
super.beforeAll()
withJdbcStatement() { statement =>
statement.execute(s"CREATE DATABASE IF NOT EXISTS $database")
}
}

override def afterAll(): Unit = {
withJdbcStatement() { statement =>
statement.execute(s"DROP DATABASE IF EXISTS $database")
}
super.afterAll()
}

tables.foreach { tableDef =>
test(s"CREATE ${tableDef.table.qualifiedName}") {
withJdbcStatement(tableDef.table.qualifiedName) { statement =>
statement.execute(tableDef.create)
val resultSet = statement.executeQuery(s"SELECT * FROM ${tableDef.table.qualifiedName}")
assert(!resultSet.next())
val meta = resultSet.getMetaData
val fields = if (tableDef.fields.head.isPartitionKey) {
tableDef.fields.tail :+ tableDef.fields.head
} else {
tableDef.fields
}
fields.zipWithIndex.foreach { case (f, i) =>
assert(meta.getColumnName(i + 1) === f.name)
}
}

}
}
}
Loading

0 comments on commit 006016d

Please sign in to comment.