-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Modify getKeyColumns method for JsInputTable (#5600)
* Made JsInputTable.getKeyColumns and JsInputTable.getValueColumns return a Frozen/Stable Array similar to the JsTable.getColumns * Created corresponding test file ( InputTableTestGwt ) with unit tests that check both methods
- Loading branch information
1 parent
e3bf07e
commit 61f5a7a
Showing
3 changed files
with
91 additions
and
9 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
76 changes: 76 additions & 0 deletions
76
web/client-api/src/test/java/io/deephaven/web/client/api/InputTableTestGwt.java
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,76 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.web.client.api; | ||
|
||
import elemental2.core.JsArray; | ||
import jsinterop.base.Js; | ||
|
||
public class InputTableTestGwt extends AbstractAsyncGwtTestCase { | ||
private final TableSourceBuilder tables = new TableSourceBuilder() | ||
.script("from deephaven import empty_table, input_table") | ||
.script("source", | ||
"empty_table(5).update([\"A=`` + i\", \"B=`` + i * 2\", \"C=i\", \"D=i * 2\", \"E=`` + i\", \"F=`` + i * 2\",])") | ||
.script("result1", "input_table(init_table=source, key_cols=[])") | ||
.script("result2", "input_table(init_table=source, key_cols=[\"A\" , \"B\" ])") | ||
.script("result3", "input_table(init_table=source, key_cols=[\"C\"])") | ||
.script("result4", "input_table(init_table=source, key_cols=[\"E\" , \"F\" ])"); | ||
|
||
public void testInputTable() { | ||
connect(tables) | ||
.then(table("result1")) | ||
.then(JsTable::inputTable) | ||
.then(inputTable -> { | ||
JsArray<Column> keyColumns = Js.uncheckedCast(inputTable.getKeyColumns()); | ||
assertEquals(0, keyColumns.length); | ||
return null; | ||
}) | ||
.then(this::finish).catch_(this::report); | ||
|
||
connect(tables) | ||
.then(table("result2")) | ||
.then(JsTable::inputTable) | ||
.then(inputTable -> { | ||
JsArray<Column> keyColumns = Js.uncheckedCast(inputTable.getKeyColumns()); | ||
assertEquals(2, | ||
keyColumns.filter((col, idx) -> col.getName() == "A" || col.getName() == "B").length); | ||
JsArray<Column> valueColumns = Js.uncheckedCast(inputTable.getValues()); | ||
assertEquals(4, valueColumns.filter((col, idx) -> col.getName() == "C" || col.getName() == "D" | ||
|| col.getName() == "E" || col.getName() == "F").length); | ||
return null; | ||
}) | ||
.then(this::finish).catch_(this::report); | ||
|
||
connect(tables) | ||
.then(table("result3")) | ||
.then(JsTable::inputTable) | ||
.then(inputTable -> { | ||
JsArray<Column> keyColumns = Js.uncheckedCast(inputTable.getKeyColumns()); | ||
assertEquals(1, keyColumns.filter((col, idx) -> col.getName() == "C").length); | ||
JsArray<Column> valueColumns = Js.uncheckedCast(inputTable.getValues()); | ||
assertEquals(5, valueColumns.filter((col, idx) -> col.getName() == "A" || col.getName() == "B" | ||
|| col.getName() == "D" || col.getName() == "E" || col.getName() == "F").length); | ||
return null; | ||
}) | ||
.then(this::finish).catch_(this::report); | ||
|
||
connect(tables) | ||
.then(table("result4")) | ||
.then(JsTable::inputTable) | ||
.then(inputTable -> { | ||
JsArray<Column> keyColumns = Js.uncheckedCast(inputTable.getKeyColumns()); | ||
assertEquals(2, | ||
keyColumns.filter((col, idx) -> col.getName() == "E" || col.getName() == "F").length); | ||
JsArray<Column> valueColumns = Js.uncheckedCast(inputTable.getValues()); | ||
assertEquals(4, valueColumns.filter((col, idx) -> col.getName() == "A" || col.getName() == "B" | ||
|| col.getName() == "C" || col.getName() == "D").length); | ||
return null; | ||
}) | ||
.then(this::finish).catch_(this::report); | ||
} | ||
|
||
@Override | ||
public String getModuleName() { | ||
return "io.deephaven.web.DeephavenIntegrationTest"; | ||
} | ||
} |