some stuff

This commit is contained in:
Zoltan Haindrich 2023-10-04 11:04:15 +00:00
parent 2a4a3ab0d5
commit 02aac9dd27
2 changed files with 51 additions and 16 deletions

View File

@ -89,18 +89,56 @@ public class CalciteWindowQueryTest extends BaseCalciteQueryTest
}
private final String filename;
private final TestCase testCase;
public CalciteWindowQueryTest(
String filename
)
public CalciteWindowQueryTest(String filename) throws Exception
{
this.testCase= new TestCase(filename);
this.filename = filename;
}
class TestCase {
private WindowQueryTestInputClass input;
public TestCase(String filename) throws Exception {
final URL systemResource = ClassLoader.getSystemResource("calcite/tests/window/" + filename);
final Object objectFromYaml = YAML_JACKSON.readValue(systemResource, Object.class);
final ObjectMapper queryJackson = queryFramework().queryJsonMapper();
input = queryJackson.convertValue(objectFromYaml, WindowQueryTestInputClass.class);
Function<Object, String> jacksonToString = value -> {
try {
return queryJackson.writeValueAsString(value);
}
catch (JsonProcessingException e) {
throw new RE(e);
}
};
}
public TestType getType()
{
return input.type;
}
public String getSql()
{
return input.sql
;
}
}
@Test
@SuppressWarnings("unchecked")
public void windowQueryTest() throws IOException
{
// TestCase tc = new TestCase();
final URL systemResource = ClassLoader.getSystemResource("calcite/tests/window/" + filename);
final Object objectFromYaml = YAML_JACKSON.readValue(systemResource, Object.class);
@ -117,12 +155,12 @@ public class CalciteWindowQueryTest extends BaseCalciteQueryTest
}
};
assumeThat(input.type, Matchers.not(TestType.failingTest));
assumeThat(testCase.getType(), Matchers.not(TestType.failingTest));
if (input.type == TestType.operatorValidation) {
if (testCase.getType() == TestType.operatorValidation) {
testBuilder()
.skipVectorize(true)
.sql(input.sql)
.sql(testCase.getSql())
.queryContext(ImmutableMap.of(PlannerContext.CTX_ENABLE_WINDOW_FNS, true,
QueryContexts.ENABLE_DEBUG, true))
.addCustomVerification(QueryVerification.ofResults(results -> {

View File

@ -2,11 +2,11 @@ type: "operatorValidation"
sql: |
SELECT
dim1,
dim2,
LAG(dim1,111) OVER ()
LAG(dim2,1) OVER ()
FROM foo
GROUP BY dim1,dim2
WHERE dim2 is null or length(dim2)>0
GROUP BY dim2
expectedOperators:
- type: "naivePartition"
@ -16,11 +16,8 @@ expectedOperators:
type: "offset"
inputColumn: "d0"
outputColumn: "w0"
offset: -111
offset: -1
expectedResults:
- ["","a",null]
- ["1","a",null]
- ["10.1",null,null]
- ["2","",null]
- ["abc",null,null]
- ["def","abc",null]
- [null,null]
- ["a",null]
- ["abc","a"]