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

DrillWindowQueryTest: use proper way to decide if the query is ordered #15118

Merged
merged 185 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
185 commits
Select commit Hold shift + click to select a range
3df0069
use enum for type + assume to mark disabled
kgyrtkirk Sep 21, 2023
21e6d9e
enable rel logging in debug
kgyrtkirk Sep 21, 2023
6de29b1
some changes
kgyrtkirk Sep 21, 2023
6ce9bbd
use local calcite; enable tests
kgyrtkirk Sep 21, 2023
53ddb34
make some tests pass
kgyrtkirk Sep 22, 2023
431ec6c
possble fix; but different format/etc; need different result cmp
kgyrtkirk Sep 22, 2023
3522ef5
parse results
kgyrtkirk Sep 22, 2023
46bcd62
unsorted
kgyrtkirk Sep 22, 2023
b8c4353
more sophisticated order match
kgyrtkirk Sep 22, 2023
be06612
asd
kgyrtkirk Sep 22, 2023
01ee94c
format
kgyrtkirk Sep 22, 2023
39f713b
crap
kgyrtkirk Sep 22, 2023
41120e2
lead/lag default 1
kgyrtkirk Sep 22, 2023
37ba5e7
add smlTbl
kgyrtkirk Sep 22, 2023
0b7a656
fix a 100 more
kgyrtkirk Sep 22, 2023
e0e1575
remove crappy class
kgyrtkirk Sep 22, 2023
628d4c6
undo comment wrap
kgyrtkirk Sep 22, 2023
baddb89
generate junit4 cases - so they can be ignored
kgyrtkirk Sep 22, 2023
181a067
Revert "generate junit4 cases - so they can be ignored"
kgyrtkirk Sep 22, 2023
af10e12
fix some literal stuff
kgyrtkirk Sep 22, 2023
4e0adb8
fix literal
kgyrtkirk Sep 22, 2023
51fb6a6
cases-crap
kgyrtkirk Sep 25, 2023
52e5f8d
try2
kgyrtkirk Sep 25, 2023
749863d
add indexes/etc
kgyrtkirk Sep 25, 2023
bceebf6
ignore some
kgyrtkirk Sep 25, 2023
3d87a29
updates
kgyrtkirk Sep 22, 2023
66a9050
remove ws; wQT
kgyrtkirk Sep 25, 2023
e92a971
remove unneeded method
kgyrtkirk Sep 25, 2023
2ce1cfb
format things
kgyrtkirk Sep 25, 2023
7af7b9d
cleanup
kgyrtkirk Sep 25, 2023
bfc230d
rename/etc
kgyrtkirk Sep 25, 2023
ac2bf6b
re-add cases
kgyrtkirk Sep 25, 2023
b7e564b
ignore some; change annotation a bit
kgyrtkirk Sep 25, 2023
081a2c6
fix long/date
kgyrtkirk Sep 25, 2023
05ae71f
fixes/ginore
kgyrtkirk Sep 25, 2023
7625b4d
ignoremore
kgyrtkirk Sep 25, 2023
6dd8c0b
a bit beter ts parsing
kgyrtkirk Sep 25, 2023
23dcc3f
fix some more
kgyrtkirk Sep 26, 2023
ce7d1eb
marks
kgyrtkirk Sep 26, 2023
bc492e0
cleanup/remove/etc
kgyrtkirk Sep 26, 2023
73c4f4e
checkstyle
kgyrtkirk Sep 26, 2023
6f82841
checkstyle
kgyrtkirk Sep 26, 2023
741459f
instanceof
kgyrtkirk Sep 26, 2023
5b249fe
fixes/etc
kgyrtkirk Sep 26, 2023
0fe39f8
fix pattern
kgyrtkirk Sep 26, 2023
15e46db
cleanup
kgyrtkirk Sep 26, 2023
7c1e2c7
remove cases.yaml
kgyrtkirk Sep 26, 2023
4f25a0d
fixup literals
kgyrtkirk Sep 26, 2023
fef9a5b
accept better
kgyrtkirk Sep 26, 2023
a0a379a
accept some
kgyrtkirk Sep 26, 2023
2fd3e88
more
kgyrtkirk Sep 26, 2023
623d110
few moerw
kgyrtkirk Sep 26, 2023
f3241c0
ignore some more
kgyrtkirk Sep 26, 2023
100315a
fix/etc few more
kgyrtkirk Sep 26, 2023
972757e
fix/etc few more
kgyrtkirk Sep 26, 2023
59fcc60
all ignored or pass
kgyrtkirk Sep 26, 2023
a502c1d
format; prepare to add DRUID_SUM back
kgyrtkirk Sep 26, 2023
4369275
enable-back/etc
kgyrtkirk Sep 26, 2023
7583003
changemessage
kgyrtkirk Sep 26, 2023
aac17c4
remove some stuff
kgyrtkirk Sep 26, 2023
69dec17
negativeTest
kgyrtkirk Sep 27, 2023
c24d479
negativeTest
kgyrtkirk Sep 27, 2023
1e33c7e
fixup
kgyrtkirk Sep 27, 2023
012bbf7
update apidoc
kgyrtkirk Sep 27, 2023
f1e9b16
Merge remote-tracking branch 'kgyrtkirk/windowing-fixes-negativetest'…
kgyrtkirk Sep 27, 2023
9af0edf
some stuiff
kgyrtkirk Sep 27, 2023
b6ca922
add time parsing; accept tests
kgyrtkirk Sep 28, 2023
ceb7558
remove parseException
kgyrtkirk Sep 28, 2023
c1e96da
sysqtest
kgyrtkirk Oct 2, 2023
9151fc6
retain orig SUM
kgyrtkirk Oct 2, 2023
68959a4
Merge remote-tracking branch 'apache/master' into windowing-fixes
kgyrtkirk Oct 3, 2023
7e2b56f
inputAccessor
kgyrtkirk Oct 3, 2023
8df9ab5
nulls x0
kgyrtkirk Oct 3, 2023
abf5bd6
Revert "nulls x0"
kgyrtkirk Oct 3, 2023
908cc9f
add test
kgyrtkirk Oct 3, 2023
284767a
x
kgyrtkirk Oct 3, 2023
66c287d
removeXYZ
kgyrtkirk Oct 3, 2023
fa85d15
migration pattern
kgyrtkirk Oct 3, 2023
06933a0
step1
kgyrtkirk Oct 3, 2023
b3f1dfa
implement/etc/finish test
kgyrtkirk Oct 3, 2023
f412344
rename test
kgyrtkirk Oct 3, 2023
36667d2
rename
kgyrtkirk Oct 3, 2023
aad8c38
some more stuff
kgyrtkirk Oct 3, 2023
4998e1c
move some stuff outside
kgyrtkirk Oct 3, 2023
4237989
one more
kgyrtkirk Oct 3, 2023
95d1402
more
kgyrtkirk Oct 3, 2023
6e18d01
fix a few more
kgyrtkirk Oct 3, 2023
3360c8c
finish core aggs
kgyrtkirk Oct 3, 2023
ef50c29
Merge remote-tracking branch 'apache/master' into windowing-fixes
kgyrtkirk Oct 4, 2023
bd55afd
fixes
kgyrtkirk Oct 4, 2023
5cf1e2c
check for latest rewrite place
kgyrtkirk Oct 4, 2023
c4ff274
Revert "check for latest rewrite place"
kgyrtkirk Oct 4, 2023
89844e9
some stuff
kgyrtkirk Oct 4, 2023
ed5d100
update test output
kgyrtkirk Oct 4, 2023
2a4a3ab
updates to test ouptuts
kgyrtkirk Oct 4, 2023
02aac9d
some stuff
kgyrtkirk Oct 4, 2023
a9877c4
move validator
kgyrtkirk Oct 4, 2023
f104ce4
cleanup
kgyrtkirk Oct 4, 2023
145fe82
fix
kgyrtkirk Oct 4, 2023
761cd68
change test slightly
kgyrtkirk Oct 4, 2023
a10fe7a
add apidoc cleanup warnings
kgyrtkirk Oct 4, 2023
6082df5
cleanup/etc
kgyrtkirk Oct 4, 2023
34a6aeb
instead of telling the story; add a fail with some reason whats the i…
kgyrtkirk Oct 4, 2023
9b74ef5
Merge remote-tracking branch 'apache/master' into windowing-fix-test-cmp
kgyrtkirk Oct 4, 2023
e376ae9
lead-lag fix
kgyrtkirk Oct 4, 2023
cd8fe62
Merge remote-tracking branch 'apache/master' into windowing-fixes
kgyrtkirk Oct 4, 2023
76838d1
w/o typesys modification
kgyrtkirk Oct 5, 2023
362f796
Revert "w/o typesys modification"
kgyrtkirk Oct 5, 2023
1acd53b
add test
kgyrtkirk Oct 5, 2023
a708ef2
remove unnecessary throw
kgyrtkirk Oct 5, 2023
fe6c32c
Revert "Revert "w/o typesys modification""
kgyrtkirk Oct 5, 2023
ca8dcdd
undo inputaccessor
kgyrtkirk Oct 5, 2023
c39b628
remove unrelated testcase
kgyrtkirk Oct 5, 2023
52b99e3
cleanup
kgyrtkirk Oct 5, 2023
0bebc12
cleanup
kgyrtkirk Oct 5, 2023
ffec495
cleanup/etc
kgyrtkirk Oct 5, 2023
94cbc6b
remove throws
kgyrtkirk Oct 5, 2023
ee78be5
fix warning
kgyrtkirk Oct 5, 2023
459957e
newline
kgyrtkirk Oct 5, 2023
819705d
dont use org.apache.curator.shaded.com.google.common.primitives.Doubles
kgyrtkirk Oct 5, 2023
8fa0664
druidexception-trial
kgyrtkirk Oct 5, 2023
b484606
Revert "druidexception-trial"
kgyrtkirk Oct 5, 2023
2858ff6
undo changes to no_grouping; add no_grouping2
kgyrtkirk Oct 5, 2023
2e91d7c
Merge remote-tracking branch 'apache/master' into windowing-fix-test-cmp
kgyrtkirk Oct 6, 2023
0613caf
Merge remote-tracking branch 'apache/master' into windowing-fixes
kgyrtkirk Oct 6, 2023
4ab39b6
fix conflict
kgyrtkirk Oct 6, 2023
6dbffce
messages
kgyrtkirk Oct 6, 2023
ac0b441
address comments; fix huge bug in verify
kgyrtkirk Oct 6, 2023
00479f2
remove approx
kgyrtkirk Oct 6, 2023
c473f01
tries to fix t_alltypes
kgyrtkirk Oct 6, 2023
3804c77
Revert "tries to fix t_alltypes"
kgyrtkirk Oct 6, 2023
454ae36
annotate some more tests
kgyrtkirk Oct 6, 2023
e9aa601
cleanup
kgyrtkirk Oct 6, 2023
2fa47c6
update/ignore all failing
kgyrtkirk Oct 6, 2023
7c23b5e
reorder
kgyrtkirk Oct 6, 2023
7d064b2
rename annotation
kgyrtkirk Oct 6, 2023
9a80c89
add missing assert on resultcount
kgyrtkirk Oct 6, 2023
ee2b35d
rename method; update
kgyrtkirk Oct 9, 2023
4e216b7
introduce enum/etc
kgyrtkirk Oct 9, 2023
5d0fcc0
make resultmatchmode accessible from TestBuilder#expectedResults
kgyrtkirk Oct 9, 2023
0ddd3be
fix dump results to use log
kgyrtkirk Oct 9, 2023
3d82b4e
undo annot rename
kgyrtkirk Oct 9, 2023
045f34b
Merge remote-tracking branch 'apache/master' into windowing-fixes
kgyrtkirk Oct 9, 2023
aa8e888
fix after master merge
kgyrtkirk Oct 9, 2023
9f3df59
plus2;minus2;alter1
kgyrtkirk Oct 9, 2023
8f8bed5
move parsing to new method
kgyrtkirk Oct 9, 2023
147811e
first repro of 0 long
kgyrtkirk Oct 9, 2023
b35a9a2
add registry
kgyrtkirk Oct 9, 2023
6438967
all types affected
kgyrtkirk Oct 9, 2023
cdfc3f2
undo windowing changes
kgyrtkirk Oct 9, 2023
73e9c8e
NotYetSupported instead fixme
kgyrtkirk Oct 9, 2023
f0a6a7d
remove logging stuff
kgyrtkirk Oct 9, 2023
80034be
update javadoc
kgyrtkirk Oct 9, 2023
80ee374
Merge remote-tracking branch 'apache/master' into windowing-fixes
kgyrtkirk Oct 9, 2023
8d75371
fixcheckstyle
kgyrtkirk Oct 9, 2023
dcaa67b
undo non-desired test changes
kgyrtkirk Oct 9, 2023
2c24086
capture sqlNode
kgyrtkirk Oct 10, 2023
4073f5e
Merge remote-tracking branch 'apache/master' into windowing-fix-test-cmp
kgyrtkirk Oct 10, 2023
80c67a7
Merge branch 'windowing-fix-test-cmp' into windowing-fixes
kgyrtkirk Oct 10, 2023
279e42c
make queryTResults compat
kgyrtkirk Oct 10, 2023
b0fcf63
use hook to get access to sqlNode
kgyrtkirk Oct 10, 2023
3b0d184
add comment/etc
kgyrtkirk Oct 10, 2023
6e465ea
Merge remote-tracking branch 'apache/master' into windowing-fixes
kgyrtkirk Oct 10, 2023
47e81d8
Merge remote-tracking branch 'apache/master' into windowing-fix-test-cmp
kgyrtkirk Oct 10, 2023
edea152
fix
kgyrtkirk Oct 10, 2023
de099c6
handle null correctly
kgyrtkirk Oct 10, 2023
4e5000a
Merge branch 'windowing-fix-test-cmp' into windowing-fixes-isorderby
kgyrtkirk Oct 10, 2023
5d8d662
cleanup
kgyrtkirk Oct 10, 2023
e018b2c
disable feature type based things for MSQ
kgyrtkirk Oct 10, 2023
a74a9fd
fix varianssqlaggtest
kgyrtkirk Oct 10, 2023
185b8e7
use eps in other test
kgyrtkirk Oct 10, 2023
6f79684
Merge branch 'windowing-fix-test-cmp' into windowing-fixes-isorderby
kgyrtkirk Oct 10, 2023
ed1bb89
fix intellij error
kgyrtkirk Oct 10, 2023
91b1be9
add final
kgyrtkirk Oct 11, 2023
df73774
addrss review
kgyrtkirk Oct 11, 2023
7714e2f
update test/string/etc
kgyrtkirk Oct 11, 2023
78d1d31
write concat in 3 lines :D
kgyrtkirk Oct 11, 2023
6791413
Merge branch 'windowing-fix-test-cmp' into windowing-fixes-isorderby
kgyrtkirk Oct 11, 2023
a759bc8
Merge remote-tracking branch 'apache/master' into windowing-fixes-iso…
kgyrtkirk Oct 11, 2023
83549cc
Merge remote-tracking branch 'apache/master' into windowing-fixes-iso…
kgyrtkirk Oct 12, 2023
19d35ba
Merge remote-tracking branch 'apache/master' into windowing-fixes-iso…
kgyrtkirk Oct 17, 2023
6bf679d
Merge remote-tracking branch 'apache/master' into windowing-fixes-iso…
kgyrtkirk Oct 18, 2023
f944d04
correct checkstyle
kgyrtkirk Oct 20, 2023
63b9b37
use PlannerCaptureHook for now
kgyrtkirk Oct 23, 2023
0318132
Merge remote-tracking branch 'kgyrtkirk/windowing-fixes-isorderby' in…
kgyrtkirk Oct 23, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public void validate()
catch (SqlParseException e1) {
throw translateException(e1);
}
hook.captureSqlNode(root);
handler = createHandler(root);
handler.validate();
plannerContext.setResourceActions(handler.resourceActions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.apache.calcite.rel.RelRoot;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.sql.SqlInsert;
import org.apache.calcite.sql.SqlNode;
import org.apache.druid.guice.annotations.UnstableApi;
import org.apache.druid.sql.calcite.rel.DruidRel;

/**
Expand All @@ -32,9 +34,13 @@
* none at the points where tests want to verify, except for the opportunity to
* capture the native query.
*/
@UnstableApi
public interface PlannerHook
{
void captureSql(String sql);
default void captureSqlNode(SqlNode node)
{
}
void captureQueryRel(RelRoot rootQueryRel);
void captureDruidRel(DruidRel<?> druidRel);
void captureBindableRel(BindableRel bindableRel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,7 @@ public void verify(String sql, QueryResults queryResults)
}
catch (AssertionError e) {
log.info("sql: %s", sql);
log.info(resultsToString("Expected", expectedResults));
log.info(resultsToString("Actual", queryResults.results));
throw e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.google.common.collect.Iterators;
import com.google.common.io.ByteStreams;
import com.google.inject.Injector;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql2rel.SqlToRelConverter;
import org.apache.commons.io.FileUtils;
import org.apache.druid.common.config.NullHandling;
import org.apache.druid.data.input.InputRow;
Expand Down Expand Up @@ -52,6 +54,7 @@
import org.apache.druid.sql.calcite.NotYetSupported.Modes;
import org.apache.druid.sql.calcite.NotYetSupported.NotYetSupportedProcessor;
import org.apache.druid.sql.calcite.QueryTestRunner.QueryResults;
import org.apache.druid.sql.calcite.planner.PlannerCaptureHook;
import org.apache.druid.sql.calcite.planner.PlannerContext;
import org.apache.druid.sql.calcite.util.SpecificSegmentsQuerySegmentWalker;
import org.apache.druid.timeline.DataSegment;
Expand Down Expand Up @@ -363,7 +366,8 @@ public void verify(String sql, QueryResults queryResults)
List<Object[]> expectedResults = parseResults(currentRowSignature, expectedResultsText);
try {
Assert.assertEquals(StringUtils.format("result count: %s", sql), expectedResultsText.size(), results.size());
if (!isOrdered(sql)) {
if (!isOrdered(queryResults)) {
// in case the resultset is not ordered; order via the same comparator before comparision
results.sort(new ArrayRowCmp());
expectedResults.sort(new ArrayRowCmp());
}
Expand All @@ -377,12 +381,10 @@ public void verify(String sql, QueryResults queryResults)
}
}

private boolean isOrdered(String sql)
private boolean isOrdered(QueryResults queryResults)
{
// FIXME: SqlToRelConverter.isOrdered(null) would be better
sql = sql.toLowerCase(Locale.ENGLISH).replace('\n', ' ');
sql = sql.substring(sql.lastIndexOf(')'));
return sql.contains("order");
SqlNode sqlNode = ((PlannerCaptureHook) queryResults.capture).getSqlNode();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SqlNode sqlNode = ((PlannerCaptureHook) queryResults.capture).getSqlNode();
SqlNode sqlNode = queryResults.capture.getSqlNode();

this can be done in any later change, no need to run CI for this!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure; I think my IDE will remove this cast right away when I next change that file

return SqlToRelConverter.isOrdered(sqlNode);
}
}

Expand Down Expand Up @@ -477,6 +479,7 @@ public void windowQueryTest()
.skipVectorize(true)
.queryContext(ImmutableMap.of(
PlannerContext.CTX_ENABLE_WINDOW_FNS, true,
PlannerCaptureHook.NEED_CAPTURE_HOOK, true,
QueryContexts.ENABLE_DEBUG, true)
)
.sql(testCase.getQueryString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ public interface QueryRunStepFactory
*/
public abstract static class QueryRunStep
{
private final QueryTestBuilder builder;
protected final QueryTestBuilder builder;

public QueryRunStep(final QueryTestBuilder builder)
{
this.builder = builder;
}

public QueryTestBuilder builder()
public final QueryTestBuilder builder()
{
return builder;
}
Expand Down Expand Up @@ -207,12 +207,10 @@ public void run()
public abstract static class BaseExecuteQuery extends QueryRunStep
{
protected final List<QueryResults> results = new ArrayList<>();
protected final boolean doCapture;

public BaseExecuteQuery(QueryTestBuilder builder)
{
super(builder);
doCapture = builder.expectedLogicalPlan != null;
}

public List<QueryResults> results()
Expand Down Expand Up @@ -278,7 +276,7 @@ public QueryResults runQuery(
)
{
try {
final PlannerCaptureHook capture = doCapture ? new PlannerCaptureHook() : null;
final PlannerCaptureHook capture = getCaptureHook();
final DirectStatement stmt = sqlStatementFactory.directStatement(query);
stmt.setHook(capture);
final Sequence<Object[]> results = stmt.execute().getResults();
Expand All @@ -300,6 +298,14 @@ public QueryResults runQuery(
}
}

private PlannerCaptureHook getCaptureHook()
{
if (builder.getQueryContext().containsKey(PlannerCaptureHook.NEED_CAPTURE_HOOK) || builder.expectedLogicalPlan != null) {
return new PlannerCaptureHook();
}
return null;
}

public static Pair<RowSignature, List<Object[]>> getResults(
final SqlStatementFactory sqlStatementFactory,
final SqlQueryPlus query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,29 @@
import org.apache.calcite.rel.RelRoot;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.sql.SqlInsert;
import org.apache.calcite.sql.SqlNode;
import org.apache.druid.sql.calcite.rel.DruidRel;

public class PlannerCaptureHook implements PlannerHook
{
public static final String NEED_CAPTURE_HOOK = "need_capture_hook";

private RelRoot relRoot;
private SqlInsert insertNode;
private SqlNode sqlNode;

@Override
public void captureSql(String sql)
{
// Not used at present. Add a field to capture this if you need it.
}

@Override
public void captureSqlNode(SqlNode node)
{
this.sqlNode = node;
}

@Override
public void captureQueryRel(RelRoot rootQueryRel)
{
Expand Down Expand Up @@ -75,4 +85,9 @@ public SqlInsert insertNode()
{
return insertNode;
}

public SqlNode getSqlNode()
{
return sqlNode;
}
}