Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a "random record" column to the all_types table #27

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/test/scala/com/rawlabs/das/mock/DASMock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ class DASMock(options: Map[String, String]) extends DASSdk with StrictLogging {
.setName("intField")
.setTipe(Type.newBuilder().setInt(IntType.newBuilder()).build())
.build())
.addAtts(AttrType
.newBuilder()
.setName("decimalField")
.setTipe(Type.newBuilder().setDecimal(DecimalType.newBuilder()).build()))
.addAtts(AttrType
.newBuilder()
.setName("binaryField")
Expand All @@ -252,6 +256,11 @@ class DASMock(options: Map[String, String]) extends DASSdk with StrictLogging {
.build())
.build())
.build())
.addColumns(ColumnDefinition
.newBuilder()
.setName("random_record_col")
.setType(Type.newBuilder().setRecord(RecordType.newBuilder().build()).build())
.build())
.addColumns(
ColumnDefinition
.newBuilder()
Expand Down
20 changes: 20 additions & 0 deletions src/test/scala/com/rawlabs/das/mock/DASMockAllTypesTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ class DASMockAllTypesTable(maxRows: Int) extends DASTable {
.newBuilder()
.setName("intField")
.setValue(Value.newBuilder().setInt(ValueInt.newBuilder().setV(i).build()).build()))
.addAtts(ValueRecordAttr
.newBuilder()
.setName("decimalField")
.setValue(
Value.newBuilder().setDecimal(ValueDecimal.newBuilder().setV(i.toString).build()).build()))
.addAtts(
ValueRecordAttr
.newBuilder()
Expand Down Expand Up @@ -180,6 +185,21 @@ class DASMockAllTypesTable(maxRows: Int) extends DASTable {
.build())
record.build()
},
"random_record_col" -> {
// Generate a random record (with random number of attributes of random names)
val record = ValueRecord
.newBuilder()
(1 to (i % 5)).map { j =>
record.addAtts(
ValueRecordAttr
.newBuilder()
.setName(s"attr$j")
.setValue(
Value.newBuilder().setString(ValueString.newBuilder().setV(s"random value $j").build()).build())
.build())
}
Value.newBuilder().setRecord(record.build()).build()
},
"str_record_col" -> {
val record = Value
.newBuilder()
Expand Down
Loading