Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
SPARK-23877: Validate metadata-only filters are pushed down.
  • Loading branch information
rdblue committed Apr 18, 2018
commit 6e0685e837aee90021e57a23181cb83d957f12cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.spark.sql.hive

import org.scalatest.BeforeAndAfter

import org.apache.spark.metrics.source.HiveCatalogMetrics
import org.apache.spark.sql.QueryTest
import org.apache.spark.sql.hive.test.TestHiveSingleton
import org.apache.spark.sql.test.SQLTestUtils

class OptimizeHiveMetadataOnlyQuerySuite extends QueryTest with TestHiveSingleton
with BeforeAndAfter with SQLTestUtils {

test("SPARK-23877: validate metadata-only query pushes filters to metastore") {
withTable("metadata_only") {
sql("CREATE TABLE metadata_only (id bigint, data string) PARTITIONED BY (part int)")
(0 to 100).foreach(p => sql(s"ALTER TABLE metadata_only ADD PARTITION (part=$p)"))

// verify the number of matching partitions
assert(sql("SELECT DISTINCT part FROM metadata_only WHERE part < 10").collect.size === 10)

// verify that the partition predicate was pushed down to the metastore
assert(HiveCatalogMetrics.METRIC_PARTITIONS_FETCHED.getCount === 10)
}
}
}