FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support CnosDB by ZuoTiJia · Pull Request #697 · sqlancer/sqlancer · GitHub

Support CnosDB - #697

Merged
mrigger merged 7 commits into
sqlancer:masterfrom
cnosdb:master
Jan 28, 2023
Merged

Support CnosDB#697
mrigger merged 7 commits into
sqlancer:masterfrom
cnosdb:master

Conversation

Copy link
Copy Markdown
Contributor

Hello, I am from the CnosDB development team. We implemented Sqlancer of CnosDB referring to the code of Postgres in Sqlancer. This tool helped us find some bugs.

mrigger commented Jan 18, 2023

Copy link
Copy Markdown
Contributor

Awesome, thanks for the PR! Starting to review the PR asap. In the meanwhile, could you please execute mvn -B verify -DskipTests=true and fix the warnings?

Copy link
Copy Markdown
Contributor Author

Awesome, thanks for the PR! Starting to review the PR asap. In the meanwhile, could you please execute mvn -B verify -DskipTests=true and fix the warnings?

Thank you for reminding

mrigger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks a lot for the PR! Could you please take a look at my comments, which are minor issues and suggestions?

Currently, the implementation contains much effectively dead code, namely the getExpectedValue methods needed for Pivoted Query Synthesis (PQS), which is not supported as a test oracle. Would it be possible to remove these methods?

private CnosDBComparatorHelper() {
}

public static boolean isEqualDouble(String first, String second) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

For this and other methods, is there actually a need to re-implement them? It seems that, at least for this method and the one below, the code is the same as for

public static boolean isEqualDouble(String first, String second) {
try {
double val = Double.parseDouble(first);
double secVal = Double.parseDouble(second);
return equals(val, secVal);
} catch (Exception e) {
return false;
}
}
static boolean equals(double a, double b) {
if (a == b) {
return true;
}
// If the difference is less than epsilon, treat as equal.
return Math.abs(a - b) < 0.001 * Math.max(Math.abs(a), Math.abs(b)) + 0.001;
}

String queryString = query.getLogString();
String newQueryString = "-- " + queryString;
ExpectedErrors errors = new ExpectedErrors();
errors.addAll(CnosDBExpectedError.expectedErrors());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I believe that commenting out a SQL statement should not result in any errors, so the expected errors could be empty here?

import sqlancer.common.query.ExpectedErrors;
import sqlancer.common.query.Query;

public class CnosDBLoggableFactory extends LoggableFactory {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think inheriting from

public class SQLLoggableFactory extends LoggableFactory {
and overriding methods whose implementation differs would prevent some code duplication here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I noticed that this is still unaddressed. Is it not possible to inherit because of some reason related to not using JDBC?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

At present, our implementation does not use JDBC. At the beginning of development, JDBC support was not perfect, so we used the http interface, and we will optimize it later.

},
SUM(CnosDBDataType.INT, CnosDBDataType.DOUBLE, CnosDBDataType.UINT), APPROX_MEDIAN(CnosDBDataType.DOUBLE);

// Currently these aggregate functions have bugs https://github.com/cnosdb/cnosdb/issues/786

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

As an optional suggestion, I think it would be more elegant to include the currently commented-out code. If, for example, you require a random aggregate function, you could still remove the buggy aggregate functions from the selection. The general pattern is described at https://github.com/sqlancer/sqlancer/blob/67751dc3d83b880cd8c7ed53416b8b157a2ba2ea/CONTRIBUTING.md#implementing-support-for-a-new-dbms, and I see you added a CnosDBBugs class already.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks. I removed the comment and applied that pattern.

}

@Override
public CnosDBConstant getExpectedValue() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Currently, the PR includes many getExpectedValue implementations, but does not support PQS, for which they are needed. Perhaps we can remove these implementations?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks, I remove those dead code.

}

};
// NULL_IF(2, "nullif") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Perhaps we can remove this commented-out code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks, I remove those comment.

DATA_PART("date_part", CnosDBDataType.INT, CnosDBDataType.STRING, CnosDBDataType.TIMESTAMP);

// because bug of arrow-csv https://github.com/apache/arrow-rs/issues/3547
// NOW("now", CnosDBDataType.TIMESTAMP),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

As an optional suggestion, as in the other instance, we could apply the CnosDBBugs pattern here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks, I remove those comment.

Copy link
Copy Markdown
Contributor Author

Thanks for your review, I removed some dead code.

ZuoTiJia requested a review from mrigger January 20, 2023 03:50
}

public static List<String> expectedErrors() {
List<String> errors = new ArrayList<>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Here, it would be ideal to directly create an ExpectedError object rather than a list.

mrigger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Almost ready to merge! Could you please still have a look at the other comments?

state.getState().getLocalState().log(String.format("%s\n%s", firstQueryString, secondQueryString));
String assertionMessage = String.format("the size of the result sets mismatch (%d and %d)!\n%s\n%s",
resultSet.size(), secondResultSet.size(), firstQueryString, secondQueryString);
Main.nrUnsuccessfulActions.addAndGet(1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The most recent commit added a couple of Main.nrUnsuccessfulActions.addAndGet(1); and similar calls like this. I believe we should remove them to not let the two comparator helper classes diverge until we fix the code duplication problem.

ERRORS.add("Coercion from");
}

public static ExpectedErrors expectedErrors() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think that this method should be called getExpectedExpressionErrors since all the errors seem specific to expressions? This is something that could be done in a future PR.

ZuoTiJia requested a review from mrigger January 28, 2023 09:36

mrigger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, thanks a lot again for your contribution! It would be great to add CI tests (e.g., see

name: DBMS Tests (CockroachDB)
) as one of the next steps, so we make sure that the implementation does not break in the future.

mrigger commented Jan 28, 2023

Copy link
Copy Markdown
Contributor

The branch is currently out-of-date. Could please merge latest the latest master? It seems I don't have permissions to do so.

Copy link
Copy Markdown
Contributor Author

LGTM, thanks a lot again for your contribution! It would be great to add CI tests (e.g., see

name: DBMS Tests (CockroachDB)

) as one of the next steps, so we make sure that the implementation does not break in the future.

we'll add it soon

mrigger merged commit 354d591 into sqlancer:master Jan 28, 2023

mrigger commented Jan 28, 2023

Copy link
Copy Markdown
Contributor

Thanks a lot!

ZuoTiJia mentioned this pull request Jan 29, 2023
4 tasks
This file contains hidden or 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL