Skip to content

Commit

Permalink
fix the case of predicate push down when query apps table with equalT…
Browse files Browse the repository at this point in the history
…o or in some specific state(s)
  • Loading branch information
naive-zhang committed Dec 20, 2024
1 parent 15ea677 commit 531d33c
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

package org.apache.kyuubi.spark.connector.yarn

import scala.collection.JavaConverters._
import scala.collection.mutable
import scala.jdk.CollectionConverters.asScalaBufferConverter

import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.yarn.api.records.{ApplicationId, ApplicationReport, YarnApplicationState}
import org.apache.hadoop.yarn.client.api.YarnClient
Expand All @@ -31,6 +27,10 @@ import org.apache.spark.sql.connector.read.PartitionReader
import org.apache.spark.sql.sources.{EqualTo, In}
import org.apache.spark.unsafe.types.UTF8String

import scala.collection.JavaConverters._
import scala.collection.mutable
import scala.jdk.CollectionConverters.asScalaBufferConverter

class YarnAppPartitionReader(yarnAppPartition: YarnAppPartition)
extends PartitionReader[InternalRow] with Logging {

Expand Down Expand Up @@ -79,7 +79,7 @@ class YarnAppPartitionReader(yarnAppPartition: YarnAppPartition)
case EqualTo("id", appId: String) => java.util.Collections.singletonList(
yarnClient.getApplicationReport(ApplicationId.fromString(appId)))
case EqualTo("state", state: String) =>
state.toUpperCase match {
state match {
case validState if validYarnStateSet.contains(validState) =>
yarnClient.getApplications(
java.util.EnumSet.of(YarnApplicationState.valueOf(validState)))
Expand All @@ -89,7 +89,7 @@ class YarnAppPartitionReader(yarnAppPartition: YarnAppPartition)
yarnClient.getApplications(java.util.Collections.singleton(appType))
case In("state", states: Array[Any]) => yarnClient.getApplications(
java.util.EnumSet.copyOf(states
.map(x => x.toString.toUpperCase)
.map(x => x.toString)
.filter(x => validYarnStateSet.contains(x))
.map(x =>
YarnApplicationState.valueOf(x)).toList.asJava))
Expand Down

0 comments on commit 531d33c

Please sign in to comment.