-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
DOC: Add examples to the SQL docs #31633
Conversation
Pinging @elastic/es-search-aggs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with new CSV files and a new data set. Could we get away without DocsCsvSpecTestCase
/JdbcDocCsvSpectIT
if we do it during the regular CSV tests. If we're worried about time we could use `-Dtests.method='docs'?
makeAlias(client, "test_alias", "test_emp", "test_emp_copy"); | ||
makeAlias(client, "test_alias_emp", "test_emp", "test_emp_copy"); | ||
} | ||
|
||
protected static void loadDocsDatasetIntoEs(RestClient client) throws Exception { | ||
loadEmpDatasetIntoEs(client, "emp"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to rename the one in tests to emp
and load the library
one for all the tests.
I ended up with a different test since for tests we have a number of indices that show up in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me. I'd prefer to figure out a way around it, but that can come later. I left one important thing and one minor structural thing.
// uncomment this to printout the result set and create new CSV tests | ||
// | ||
JdbcTestUtils.logLikeCLI(elastic, log); | ||
//JdbcAssert.assertResultSets(expected, elastic, log); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This look like it isn't asserting anything. I don't mind the printing being enabled all the time but I think we should have the assert on, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right - the comment will disappear in the final commit. I'm printing stuff out to help with the docs (logging while asserting adds the log header which makes it harder to copy-paste the text output).
* That's not to say the two cannot be merged however that felt like too much of an effort | ||
* at this stage and, to not keep things stalling, started with this approach. | ||
*/ | ||
public abstract class DocsCsvSpecTestCase extends SpecBaseIntegrationTestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you flatten this into into the JDBC spec test case so we don't have an abstract class with a single non-abstract child?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roger that.
Significantly improve the example snippets in the documentation. The examples are part of the test suite and checked nightly. To help readability, the existing dataset was extended (test_emp renamed to emp plus library).
Add examples to all sections Fix two minor bugs in the JDBC driver discovered Improve output of JDBC tests to be consistent with the CLI Add lenient flag to JDBC asserts to allow type widening (a long is equivalent to a integer as long as the value is the same)
Pushed the changes (including a rebase from master which looks like it didn't delete the existing comments probably because the commit itself was kept in place). I've improved the tests and added example through-out the rest of the docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few questions. I still think the approach is good but have some questions about smaller parts of it.
// TESTRESPONSE[_cat] | ||
["source","sql",subs="attributes,callouts,macros"] | ||
---- | ||
include-tagged::{sql-specs}/docs.csv-spec[orderByScore] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
x-pack/qa/sql/build.gradle
Outdated
@@ -10,6 +10,8 @@ dependencies { | |||
|
|||
// JDBC testing dependencies | |||
compile project(path: xpackModule('sql:jdbc'), configuration: 'nodeps') | |||
compile project(path: xpackModule('sql:sql-proto')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not needed anymore since we depend on sql-action
(it's redundant) so I removed it.
x-pack/qa/sql/build.gradle
Outdated
@@ -85,6 +88,8 @@ subprojects { | |||
} | |||
testCompile "org.elasticsearch.test:framework:${version}" | |||
|
|||
testCompile project(path: xpackModule('sql:sql-proto')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed as well (since everything got folded back to qa-sql).
// uncomment this to printout the result set and create new CSV tests | ||
// | ||
//JdbcTestUtils.logLikeCLI(elastic, log); | ||
JdbcAssert.assertResultSets(expected, elastic, log, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the headers don't have to encode the type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the lenient is set to true, the types are widened and only the values are compared.
@@ -344,7 +344,7 @@ public Object getObject(int columnIndex) throws SQLException { | |||
throw new SQLException("type is null"); | |||
} | |||
|
|||
return getObject(columnIndex, type); | |||
return convert(columnIndex, type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this includes the jdbc fix, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the one (that triggers the StackOverflow).
@@ -83,17 +86,30 @@ where: | |||
`table_name`:: | |||
|
|||
Represents the name (optionally qualified) of an existing table, either a concrete or base one (actual index) or alias. | |||
|
|||
|
|||
If the table name contains special SQL characters (such as `.`,`-`,etc...) use double quotes to escape them: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth specifying a more complete list of special characters that need escaping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That needs to be a separate section (regarding the grammar in general) for a future PR.
["source","sql",subs="attributes,callouts,macros"] | ||
---- | ||
include-tagged::{sql-specs}/docs.csv-spec[orderByScoreWithMatch] | ||
---- | ||
|
||
NOTE: | ||
Trying to return `score` from a non full-text queries will return the same value for all results, as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo I believe for the query-queries: "from a non full-text queries". Should probably be singular "query" or, if using plural, "from non full-text queries".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, "equilley" -> "equally".
Significantly improve the example snippets in the documentation. The examples are part of the test suite and checked nightly. To help readability, the existing dataset was extended (test_emp renamed to emp plus library). Improve output of JDBC tests to be consistent with the CLI Add lenient flag to JDBC asserts to allow type widening (a long is equivalent to a integer as long as the value is the same). (cherry picked from commit de9e56a)
Significantly improve the example snippets in the documentation. The examples are part of the test suite and checked nightly. To help readability, the existing dataset was extended (test_emp renamed to emp plus library). Improve output of JDBC tests to be consistent with the CLI Add lenient flag to JDBC asserts to allow type widening (a long is equivalent to a integer as long as the value is the same). (cherry picked from commit de9e56a) (cherry picked from commit 77f5e17) (cherry picked from commit 093ea03) (cherry picked from commit b342552)
* 6.x: Fix not waiting for Netty ThreadDeathWatcher in IT (#31758) (#31789) [Docs] Correct default window_size (#31582) S3 fixture should report 404 on unknown bucket (#31782) [ML] Limit ML filter items to 10K (#31731) Fixture for Minio testing (#31688) [ML] Return statistics about forecasts as part of the jobsstats and usage API (#31647) [DOCS] Add missing get mappings docs to HLRC (#31765) [DOCS] Starting Elasticsearch (#31701) Fix coerce validation_method in GeoBoundingBoxQueryBuilder (#31747) Painless: Complete Removal of Painless Type (#31699) Consolidate watcher setting update registration (#31762) [DOCS] Adds empty 6.3.1 release notes page ingest: Introduction of a bytes processor (#31733) [test] don't run bats tests for suse boxes (#31749) Add analyze API to high-level rest client (#31577) Implemented XContent serialisation for GetIndexResponse (#31675) [DOCS] Typos DOC: Add examples to the SQL docs (#31633) Add support for AWS session tokens (#30414) Watcher: Reenable start/stop yaml tests (#31754) JDBC: Fix stackoverflow on getObject and timestamp conversion (#31735) Support multiple system store types (#31650) Add write*Blob option to replace existing blob (#31729) Split CircuitBreaker-related tests (#31659) Painless: Add Context Docs (#31190) Docs: Remove missing reference Migrate scripted metric aggregation scripts to ScriptContext design (#30111) Watcher: Fix chain input toXcontent serialization (#31721) Remove _all example (#31711) rest-high-level: added get cluster settings (#31706) Docs: Match the examples in the description (#31710) [Docs] Correct typos (#31720) Extend allowed characters for grok field names (#21745) (#31653) (#31722) [DOCS] Check for Windows and *nix file paths (#31648) [ML] Validate ML filter_id (#31535) Fix gradle4.8 deprecation warnings (#31654) Update numbers to reflect 4-byte UTF-8-encoded characters (#27083)
* master: [ML] Rate limit established model memory updates (#31768) [Docs] Correct default window_size (#31582) S3 fixture should report 404 on unknown bucket (#31782) Detach Transport from TransportService (#31727) [ML] Limit ML filter items to 10K (#31731) [ML] Return statistics about forecasts as part of the jobsstats and usage API (#31647) Fixture for Minio testing (#31688) [DOCS] Add missing get mappings docs to HLRC (#31765) [DOCS] Starting Elasticsearch (#31701) Painless: Complete Removal of Painless Type (#31699) Fix not waiting for Netty ThreadDeathWatcher in IT (#31758) Consolidate watcher setting update registration (#31762) Build: re-enabled bwc (#31769) ingest: Introduction of a bytes processor (#31733) Fix coerce validation_method in GeoBoundingBoxQueryBuilder (#31747) Add analyze API to high-level rest client (#31577) [DOCS] Typos DOC: Add examples to the SQL docs (#31633) Add support for AWS session tokens (#30414) Watcher: Reenable start/stop yaml tests (#31754) Implemented XContent serialisation for GetIndexResponse (#31675) JDBC: Fix stackoverflow on getObject and timestamp conversion (#31735) resolveHasher defaults to NOOP (#31723) Account for XContent overhead in in-flight breaker Split CircuitBreaker-related tests (#31659) Add write*Blob option to replace existing blob (#31729) Painless: Add Context Docs (#31190) Watcher: Fix chain input toXcontent serialization (#31721) Docs: Match the examples in the description (#31710) rest-high-level: added get cluster settings (#31706) [Docs] Correct typos (#31720) Clean up double semicolon code typos (#31687) [DOCS] Check for Windows and *nix file paths (#31648) [ML] Validate ML filter_id (#31535) Revert long lines Fix TransportChangePasswordActionTests
Wip on the documentation examples.
Put the tests into a separate suite to help with clarity and isolation.
The existing tests have different CVS tests (that include data type among other things) which are not relevant for the docs.
Also moved the library dataset into the test suite.
Additionally, used the same output from CLI in the JDBC test suite (a different PR should eliminate the JdbcTestUtils output entirely and only use the
CliFormatter
).Once the infrastructure is in place, adding the examples goes quite smooth. I also like the SQL with table approach since it's easier to read (and applicable for all consumers - REST, JDBC, CLI).