Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyu committed Aug 5, 2024
1 parent 6365088 commit 9f6afb6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@
package org.apache.paimon.spark.commands

import org.apache.paimon.spark.SparkTable
import org.apache.paimon.spark.leafnode.PaimonLeafRunnableCommand
import org.apache.paimon.spark.leafnode.{PaimonLeafCommand, PaimonLeafRunnableCommand}
import org.apache.paimon.table.FileStoreTable

import org.apache.spark.sql.{Row, SparkSession}
import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference}
import org.apache.spark.sql.types.{BinaryType, Metadata, StringType}

case class PaimonShowColumnsCommand(v2Table: SparkTable)
extends PaimonLeafRunnableCommand
extends PaimonLeafCommand
with WithFileStoreTable {
override def table: FileStoreTable = v2Table.getTable.asInstanceOf[FileStoreTable]

override def run(sparkSession: SparkSession): Seq[Row] = {
Seq.empty[Row]
}
override lazy val output: Seq[Attribute] = Seq(
AttributeReference("column", StringType, true, Metadata.empty)())

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import org.apache.paimon.spark.leafnode.PaimonLeafV2CommandExec

import org.apache.spark.sql.catalyst.InternalRow
import org.apache.spark.sql.catalyst.expressions.Attribute
import org.apache.spark.unsafe.types.UTF8String

case class PaimonShowColumnsExec(output: Seq[Attribute], v2Table: SparkTable)
extends PaimonLeafV2CommandExec {

override protected def run(): Seq[InternalRow] = {
v2Table.schema.map(sc => InternalRow.fromSeq(Seq(sc.name))).toSeq
v2Table.schema.map(sc => InternalRow.fromSeq(Seq(UTF8String.fromString(sc.name)))).toSeq
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ case class PaimonStrategy(spark: SparkSession) extends Strategy with PredicateHe
val input = buildInternalRow(args)
PaimonCallExec(c.output, procedure, input) :: Nil

case c @ PaimonShowColumnsCommand(table) =>
PaimonShowColumnsExec(c.output, table) :: Nil
case s @ PaimonShowColumnsCommand(table) =>
PaimonShowColumnsExec(s.output, table) :: Nil
case _ => Nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ package org.apache.paimon.spark.sql

import org.apache.paimon.spark.PaimonSparkTestBase

import org.apache.spark.sql.Row
import org.junit.jupiter.api.Assertions.assertDoesNotThrow

class PaimonShowColumnsTestBase extends PaimonSparkTestBase {
abstract class PaimonShowColumnsTestBase extends PaimonSparkTestBase {

test("Show columns from Paimon test") {
spark.sql(s"""
Expand All @@ -42,6 +43,10 @@ class PaimonShowColumnsTestBase extends PaimonSparkTestBase {
spark.sql("SHOW COLUMNS FROM T")
})

checkAnswer(
spark.sql("SHOW COLUMNS FROM T"),
Row("id") :: Row("name") :: Row("i") :: Row("l") :: Nil)

}

}

0 comments on commit 9f6afb6

Please sign in to comment.