Skip to content

Commit

Permalink
add AskwangSQLQueryTest
Browse files Browse the repository at this point in the history
  • Loading branch information
askwang committed Jul 8, 2024
1 parent 0f368c9 commit dfd4207
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ public InnerTableScan withFilter(Predicate predicate) {

@Override
public Plan innerPlan() {
return () -> Collections.singletonList(new SnapshotsSplit(location));
// return () -> Collections.singletonList(new SnapshotsSplit(location));
return new Plan() {
@Override
public List<Split> splits() {
return Collections.singletonList(new SnapshotsSplit(location));
}
};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ abstract class PaimonBaseScanBuilder(table: Table)
val visitor = new PartitionPredicateVisitor(table.partitionKeys())
filters.foreach {
filter =>
// 将 EqualTo(dt,2024-04-11 11:01:00.0)] 转为为 Equal(dt, 2024-04-11T11:01)]
// spark 引擎这里没有做转换
val predicate = converter.convertIgnoreFailure(filter)
if (predicate == null) {
postScan.append(filter)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

/*
* 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.paimon.spark.sql

import org.apache.paimon.spark.PaimonSparkTestBase

/**
* @author askwang
* @date 2024/7/6
*/
class AskwangSQLQueryTest extends PaimonSparkTestBase{

test("select timestamp field by where for append table") {
withTable("tb") {
spark.conf.set("spark.sql.planChangeLog.level", "INFO")
println("version: " + sparkVersion)
spark.sql(s"CREATE TABLE tb (id INT, dt TIMESTAMP) using paimon TBLPROPERTIES ('file.format'='parquet')")
val ds = sql("INSERT INTO `tb` VALUES (1,cast(\"2024-04-11 11:01:00\" as Timestamp))")
val data = sql("SELECT * FROM `tb` where dt ='2024-04-11 11:01:00' ")
println(data.queryExecution)
println(data.show())
println("=====")
println(data.explain(true))
}
}
}

0 comments on commit dfd4207

Please sign in to comment.