Skip to content

Commit

Permalink
Added an all_types table
Browse files Browse the repository at this point in the history
  • Loading branch information
bgaidioz committed Nov 19, 2024
1 parent a968d74 commit 8585d24
Show file tree
Hide file tree
Showing 2 changed files with 709 additions and 2 deletions.
338 changes: 336 additions & 2 deletions src/main/scala/com/rawlabs/das/mock/DASMock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,27 @@ package com.rawlabs.das.mock

import com.rawlabs.das.sdk._
import com.rawlabs.protocol.das.{ColumnDefinition, FunctionDefinition, TableDefinition, TableId}
import com.rawlabs.protocol.raw.{IntType, StringType, Type}
import com.rawlabs.protocol.raw.{
AnyType,
AttrType,
BinaryType,
BoolType,
ByteType,
DateType,
DecimalType,
DoubleType,
FloatType,
IntType,
IntervalType,
ListType,
LongType,
RecordType,
ShortType,
StringType,
TimeType,
TimestampType,
Type
}
import com.typesafe.scalalogging.StrictLogging

/**
Expand Down Expand Up @@ -100,6 +120,320 @@ class DASMock(options: Map[String, String]) extends DASSdk with StrictLogging {
.build()
)
.setStartupCost(2000)
.build(),
TableDefinition
.newBuilder()
.setTableId(TableId.newBuilder().setName("all_types"))
.setDescription("All types including nested types")
.addColumns(
ColumnDefinition
.newBuilder()
.setName("byte_col")
.setType(Type.newBuilder().setByte(ByteType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("short_col")
.setType(Type.newBuilder().setShort(ShortType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("int_col")
.setType(Type.newBuilder().setInt(IntType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("long_col")
.setType(Type.newBuilder().setLong(LongType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("float_col")
.setType(Type.newBuilder().setFloat(FloatType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("double_col")
.setType(Type.newBuilder().setDouble(DoubleType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("decimal_col")
.setType(Type.newBuilder().setDecimal(DecimalType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("string_col")
.setType(Type.newBuilder().setString(StringType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("binary_col")
.setType(Type.newBuilder().setBinary(BinaryType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("bool_col")
.setType(Type.newBuilder().setBool(BoolType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("date_col")
.setType(Type.newBuilder().setDate(DateType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("time_col")
.setType(Type.newBuilder().setTime(TimeType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("timestamp_col")
.setType(Type.newBuilder().setTimestamp(TimestampType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("interval_col")
.setType(Type.newBuilder().setInterval(IntervalType.newBuilder()).build())
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("any_col")
.setType(Type.newBuilder().setAny(AnyType.newBuilder()).build())
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("strings_col")
.setType(
Type
.newBuilder()
.setList(
ListType
.newBuilder()
.setInnerType(Type.newBuilder().setString(StringType.newBuilder()).build())
.build()
)
.build()
)
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("timestamps_col")
.setType(
Type
.newBuilder()
.setList(
ListType
.newBuilder()
.setInnerType(Type.newBuilder().setTimestamp(TimestampType.newBuilder()).build())
.build()
)
.build()
)
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("record_col")
.setType(
Type
.newBuilder()
.setRecord(
RecordType
.newBuilder()
.addAtts(
AttrType
.newBuilder()
.setIdn("intField")
.setTipe(Type.newBuilder().setInt(IntType.newBuilder()).build())
.build()
)
.addAtts(
AttrType
.newBuilder()
.setIdn("binaryField")
.setTipe(Type.newBuilder().setBinary(BinaryType.newBuilder()).build())
.build()
)
.addAtts(
AttrType
.newBuilder()
.setIdn("timestampField")
.setTipe(Type.newBuilder().setTimestamp(TimestampType.newBuilder()).build())
.build()
)
.build()
)
.build()
)
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("str_record_col")
.setType(
Type
.newBuilder()
.setRecord(
RecordType
.newBuilder()
.addAtts(
AttrType
.newBuilder()
.setIdn("str1")
.setTipe(Type.newBuilder().setString(StringType.newBuilder()).build())
.build()
)
.addAtts(
AttrType
.newBuilder()
.setIdn("str2")
.setTipe(Type.newBuilder().setString(StringType.newBuilder()).build())
.build()
)
.addAtts(
AttrType
.newBuilder()
.setIdn("str3")
.setTipe(Type.newBuilder().setString(StringType.newBuilder()).build())
.build()
)
.build()
)
.build()
)
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("str_records_col")
.setType(
Type
.newBuilder()
.setList(
ListType
.newBuilder()
.setInnerType(
Type
.newBuilder()
.setRecord(
RecordType
.newBuilder()
.addAtts(
AttrType
.newBuilder()
.setIdn("str1")
.setTipe(Type.newBuilder().setString(StringType.newBuilder()).build())
.build()
)
.addAtts(
AttrType
.newBuilder()
.setIdn("str2")
.setTipe(Type.newBuilder().setString(StringType.newBuilder()).build())
.build()
)
.addAtts(
AttrType
.newBuilder()
.setIdn("str3")
.setTipe(Type.newBuilder().setString(StringType.newBuilder()).build())
.build()
)
.build()
)
.build()
)
.build()
)
.build()
)
.build()
)
.addColumns(
ColumnDefinition
.newBuilder()
.setName("records_col")
.setType(
Type
.newBuilder()
.setList(
ListType
.newBuilder()
.setInnerType(
Type
.newBuilder()
.setRecord(
RecordType
.newBuilder()
.addAtts(
AttrType
.newBuilder()
.setIdn("intField")
.setTipe(Type.newBuilder().setInt(IntType.newBuilder()).build())
.build()
)
.addAtts(
AttrType
.newBuilder()
.setIdn("binaryField")
.setTipe(Type.newBuilder().setBinary(BinaryType.newBuilder()).build())
.build()
)
.addAtts(
AttrType
.newBuilder()
.setIdn("timestampField")
.setTipe(Type.newBuilder().setTimestamp(TimestampType.newBuilder()).build())
.build()
)
.addAtts(
AttrType
.newBuilder()
.setIdn("timeField")
.setTipe(Type.newBuilder().setTime(TimeType.newBuilder()).build())
)
.build()
)
.build()
)
.build()
)
)
)
.setStartupCost(1000)
.build()
)
}
Expand All @@ -111,9 +445,9 @@ class DASMock(options: Map[String, String]) extends DASSdk with StrictLogging {
case "big" => Some(new DASMockTable(2000000000))
case "small" => Some(new DASMockTable(100))
case "in_memory" => Some(new DASMockInMemoryTable(dasMockStorage))
case "all_types" => Some(new DASMockAllTypesTable(100))
case _ => None
}
}

override def getFunction(name: String): Option[DASFunction] = None
}
Loading

0 comments on commit 8585d24

Please sign in to comment.