Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from audienceproject/feature/allowColumnsWithTy…
…pesOnEmptyDataframes Allow columns with types on empty dataframes
- Loading branch information
Showing
3 changed files
with
45 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/test/scala/com/audienceproject/crossbow/core/ConstuctionTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.audienceproject.crossbow.core | ||
|
||
import com.audienceproject.crossbow.{DataFrame, expr} | ||
import com.audienceproject.crossbow.schema.{Column, Schema} | ||
import org.scalatest.funsuite.AnyFunSuite | ||
|
||
class ConstuctionTest extends AnyFunSuite { | ||
test("construct from typed empty seq") { | ||
val df = DataFrame.fromSeq(Seq.empty[(Int,Long)]) | ||
assertResult(2)(df.numColumns) | ||
assertResult(Schema(Seq(Column("_0",expr.IntType),Column("_1",expr.LongType))))(df.schema) | ||
} | ||
test("construct using implicits") { | ||
import com.audienceproject.crossbow.Implicits._ | ||
val df = Seq.empty[(Int,Long)].toDataFrame() | ||
assertResult(2)(df.numColumns) | ||
assertResult(Schema(Seq(Column("_0",expr.IntType),Column("_1",expr.LongType))))(df.schema) | ||
} | ||
|
||
test("construct with names") { | ||
import com.audienceproject.crossbow.Implicits._ | ||
val df = Seq.empty[(Int,Long)].toDataFrame("a","b") | ||
assertResult(2)(df.numColumns) | ||
assertResult(Schema(Seq(Column("a",expr.IntType),Column("b",expr.LongType))))(df.schema) | ||
} | ||
} |