diff --git a/logical-plan/src/main/kotlin/Expressions.kt b/logical-plan/src/main/kotlin/Expressions.kt index 6086284..be8abde 100644 --- a/logical-plan/src/main/kotlin/Expressions.kt +++ b/logical-plan/src/main/kotlin/Expressions.kt @@ -54,4 +54,29 @@ class LiteralLong(val n: Long): LogicalExpr { } } -fun lit(value: Long) = LiteralLong(value) \ No newline at end of file +fun lit(value: Long) = LiteralLong(value) + +class LiteralFloat(val n: Float): LogicalExpr { + override fun toField(input: LogicalPlan): Field { + return Field(n.toString(), ArrowTypes.FloatType) + } + + override fun toString(): String { + return n.toString() + } +} + +fun lit(value: Float) = LiteralFloat(value) + +class LiteralDouble(val n: Double): LogicalExpr { + override fun toField(input: LogicalPlan): Field { + return Field(n.toString(), ArrowTypes.DoubleType) + } + + override fun toString(): String { + return n.toString() + } +} + +fun lit(value: Double) = LiteralDouble(value) + diff --git a/logical-plan/src/test/kotlin/ExpressionsTest.kt b/logical-plan/src/test/kotlin/ExpressionsTest.kt index 4f4abdb..b161e6d 100644 --- a/logical-plan/src/test/kotlin/ExpressionsTest.kt +++ b/logical-plan/src/test/kotlin/ExpressionsTest.kt @@ -27,4 +27,18 @@ class ExpressionsTest { assertEquals(litStr.toString(), "10000000000") } + + @Test + fun `test LiteralFloat toString`() { + val litStr = lit(1e10.toFloat()) + + assertEquals(litStr.toString(), "1.0E10") + } + + @Test + fun `test LiteralDouble toString`() { + val litStr = lit(1e10) + + assertEquals(litStr.toString(), "1.0E10") + } } \ No newline at end of file