From 75254767c044e32f4aaae1eb4a2a1bd9aa3e2fdb Mon Sep 17 00:00:00 2001 From: KK Date: Tue, 13 Sep 2022 11:23:52 +0200 Subject: [PATCH 1/6] #255: Improved documentation --- doc/changes/changelog.md | 1 + doc/changes/changes_16.1.1.md | 11 ++++ doc/development/api/capabilities_list.md | 11 +++- doc/development/api/data_types_api.md | 4 ++ doc/development/api/scalar_functions_api.md | 22 +++---- doc/development/api/virtual_schema_api.md | 64 ++++++++++++--------- doc/error_codes.md | 3 - pk_generated_parent.pom | 2 +- pom.xml | 4 +- 9 files changed, 76 insertions(+), 46 deletions(-) create mode 100644 doc/changes/changes_16.1.1.md delete mode 100644 doc/error_codes.md diff --git a/doc/changes/changelog.md b/doc/changes/changelog.md index c231989b..0706084d 100644 --- a/doc/changes/changelog.md +++ b/doc/changes/changelog.md @@ -1,5 +1,6 @@ # Changes +* [16.1.1](changes_16.1.1.md) * [16.1.0](changes_16.1.0.md) * [16.0.0](changes_16.0.0.md) * [15.3.3](changes_15.3.3.md) diff --git a/doc/changes/changes_16.1.1.md b/doc/changes/changes_16.1.1.md new file mode 100644 index 00000000..19c9e1a2 --- /dev/null +++ b/doc/changes/changes_16.1.1.md @@ -0,0 +1,11 @@ +# Common module of Exasol Virtual Schemas Adapters 16.1.1, released 2022-09-13 + +Code name: Documentation Update + +## Summary + +Updated documentation. + +## Features + +* #255: Improved documentation diff --git a/doc/development/api/capabilities_list.md b/doc/development/api/capabilities_list.md index 3918ad2d..80765b1d 100644 --- a/doc/development/api/capabilities_list.md +++ b/doc/development/api/capabilities_list.md @@ -2,6 +2,13 @@ Here you can find a list of available Virtual Schema capabilities. +* [Main Capabilities](#main-capabilities) +* [Literal Capabilities](#literal-capabilities) +* [Predicate Capabilities](#predicate-capabilities) +* [Scalar Function Capabilities](#scalar-function-capabilities) +* [Aggregate Function Capabilities](#aggregate-function-capabilities) + + ## [Main Capabilities](../../../src/main/java/com/exasol/adapter/capabilities/MainCapability.java) - AGGREGATE_GROUP_BY_COLUMN @@ -253,7 +260,7 @@ Here you can find a list of available Virtual Schema capabilities. - FN_AGG_AVG - FN_AGG_AVG_DISTINCT - FN_AGG_COUNT -- FN_AGG_COUNT_DISTINCT +- FN_AGG_COUNT_DISTINCT - FN_AGG_COUNT_STAR - FN_AGG_COUNT_TUPLE - FN_AGG_EVERY @@ -273,7 +280,7 @@ Here you can find a list of available Virtual Schema capabilities. - FN_AGG_LISTAGG_SEPARATOR - FN_AGG_MAX - FN_AGG_MEDIAN -- FN_AGG_MIN +- FN_AGG_MIN - FN_AGG_MUL - FN_AGG_MUL_DISTINCT - FN_AGG_SOME diff --git a/doc/development/api/data_types_api.md b/doc/development/api/data_types_api.md index ae98353b..43e80675 100644 --- a/doc/development/api/data_types_api.md +++ b/doc/development/api/data_types_api.md @@ -119,3 +119,7 @@ Notes: "bytesize" : 16 } ``` + +Notes: + +* `bytesize`: Optional. The default value is `16`. diff --git a/doc/development/api/scalar_functions_api.md b/doc/development/api/scalar_functions_api.md index 1c24a7e5..d7fa9995 100644 --- a/doc/development/api/scalar_functions_api.md +++ b/doc/development/api/scalar_functions_api.md @@ -6,22 +6,22 @@ This page describes how Exasol scalar functions map to the Virtual Schemas push- ### Functions With a Common API -* [Functions without arguments](#functions-without-arguments); -* [Functions with a single argument](#functions-with-a-single-argument); -* [Functions with multiple arguments](#functions-with-multiple-arguments); -* [Arithmetic operators](#arithmetic-operators). +* [Functions without arguments](#functions-without-arguments) +* [Functions with a single argument](#functions-with-a-single-argument) +* [Functions with multiple arguments](#functions-with-multiple-arguments) +* [Arithmetic operators](#arithmetic-operators) ### Functions With a Special API This section contains functions that have a special API mapping. - + | Function Name | API Mapping Link | |-------------------|---------------------------------------------| | EXTRACT | [EXTRACT function](#extract-function) | | CASE | [CASE function](#case-function) | | CAST | [CAST function](#cast-function) | | JSON_VALUE | [JSON_VALUE function](#json_value-function) | - + ### Functions Not Included in the API This section contains Exasol functions which are not included in the API. @@ -287,12 +287,12 @@ Notes: * `results`: The different results in the same order as the arguments. If present, the ELSE result is the last entry in the `results` array. * `basis`: Optional. -Here is an example of a query containing a CASE function and its JSON representation (only the function part): +Here is an example of a query containing a CASE function and its JSON representation (only the function part): ```sql SELECT CASE grade WHEN 1 THEN 'GOOD' - WHEN 2 THEN 'FAIR' + WHEN 2 THEN 'FAIR' WHEN 3 THEN 'POOR' ELSE 'INVALID' END @@ -348,7 +348,7 @@ FROM VIRTUAL_SCHEMA_EXASOL.ALL_EXASOL_TYPES; `JSON_VALUE(arg1, arg2 RETURNING dataType {ERROR | NULL | DEFAULT exp1} ON EMPTY {ERROR | NULL | DEFAULT exp2} ON ERROR)` (requires scalar-function capability `JSON_VALUE`) - + ```json { "type": "function_scalar_json_value", @@ -385,7 +385,7 @@ Notes: A scalar function, that does not contain any column references, might be executed before reaching Virtual Schemas. That means the JSON request does not contain the scalar function, but a literal value representing its result. For example, the query `SELECT ABS(-123), c5 FROM VIRTUAL_SCHEMA_EXASOL.ALL_EXASOL_TYPES` will have the following select list: - + ```json { ... @@ -402,7 +402,7 @@ For example, the query `SELECT ABS(-123), c5 FROM VIRTUAL_SCHEMA_EXASOL.ALL_EXAS "name": "C5" } ], - + ... } ``` diff --git a/doc/development/api/virtual_schema_api.md b/doc/development/api/virtual_schema_api.md index 1d2299c1..6a0e6969 100644 --- a/doc/development/api/virtual_schema_api.md +++ b/doc/development/api/virtual_schema_api.md @@ -36,12 +36,12 @@ To get a better understanding let's take a look on how the Exasol database proce ![virtual schema query processing](../../../src/uml/requestHandling.png) -The diagram shows how Exasol handles Virtual Schema queries: +The diagram shows how Exasol handles Virtual Schema queries: -- When the core receives an SQL query on a Virtual Schema table, it first checks the capabilities of the corresponding Virtual Schema adapter. Based on that information it removes all functions and literals that are not supported by the adapter. -- Next, the Exasol Core sends a query to the Virtual Schema adapter as a `PushdownRequest`. -- The Virtual Schema adapter now rewrites the query into a new SQL statement that typically invokes the Exasol importer `IMPORT INTO ...`. For details see the [`IMPORT` statements documentation](https://docs.exasol.com/sql/import.htm). The importer statement contains a query to the external database as a string. -- Next, the Exasol database parses this statement again and invokes the importer. +- When the core receives an SQL query on a Virtual Schema table, it first checks the capabilities of the corresponding Virtual Schema adapter. Based on that information it removes all functions and literals that are not supported by the adapter. +- Next, the Exasol Core sends a query to the Virtual Schema adapter as a `PushdownRequest`. +- The Virtual Schema adapter now rewrites the query into a new SQL statement that typically invokes the Exasol importer `IMPORT INTO ...`. For details see the [`IMPORT` statements documentation](https://docs.exasol.com/sql/import.htm). The importer statement contains a query to the external database as a string. +- Next, the Exasol database parses this statement again and invokes the importer. - Finally, the Exasol core applies the functions that were not supported by the remote database itself as post processing and returns that result to the SQL client. Instead of the `IMPORT` statement the adapter can also create other SQL statements. @@ -139,7 +139,7 @@ Request to set and unset properties. The Adapter can decide whether it needs to ```json { - + "type": "setProperties", "properties": { "JDBC_CONNECTION_STRING": "new-jdbc-connection-string", @@ -158,7 +158,7 @@ Request to set and unset properties. The Adapter can decide whether it needs to The new values appear in a separate object `/properties` directly in the root element. For reference the current property values are still reported under '/schemaMetadataInfo/properties'. -Adapters must apply the properties incrementally, meaning that all parameters not explicitly listed in `/properties`, remain unchanged. +Adapters must apply the properties incrementally, meaning that all parameters not explicitly listed in `/properties`, remain unchanged. **Response:** @@ -261,24 +261,19 @@ LIMIT 10; ##### Capability Prefixes -- Main Capabilities: No prefix -- Literal Capabilities: LITERAL_ -- Predicate Capabilities: FN_PRED_ -- Scalar Function Capabilities: FN_ -- Aggregate Function Capabilities: FN_AGG_ - -See also [a list of supported Capabilities](capabilities_list.md). +See also [List of supported Capabilities](capabilities_list.md). -Capabilities can be also found in the sources of the Virtual Schema Common Java: -* [Main Capabilities](https://github.com/exasol/virtual-schema-common-java/blob/master/src/main/java/com/exasol/adapter/capabilities/MainCapability.java) -* [Literal Capabilities](https://github.com/exasol/virtual-schema-common-java/blob/master/src/main/java/com/exasol/adapter/capabilities/LiteralCapability.java) -* [Predicate Capabilities](https://github.com/exasol/virtual-schema-common-java/blob/master/src/main/java/com/exasol/adapter/capabilities/PredicateCapability.java) -* [Scalar Function Capabilities](https://github.com/exasol/virtual-schema-common-java/blob/master/src/main/java/com/exasol/adapter/capabilities/ScalarFunctionCapability.java) -* [Aggregate Function Capabilities](https://github.com/exasol/virtual-schema-common-java/blob/master/src/main/java/com/exasol/adapter/capabilities/AggregateFunctionCapability.java) +| Capability | Prefix | Java Implementation | +|---------------------------------|------------|---------------------| +| [Main Capabilities](capabilities_list.md#main-capabilities) | (none) | [MainCapability.java](https://github.com/exasol/virtual-schema-common-java/blob/master/src/main/java/com/exasol/adapter/capabilities/MainCapability.java) | +| [Literal Capabilities](capabilities_list.md#literal-capabilities) | `LITERAL_` | [LiteralCapability.java](https://github.com/exasol/virtual-schema-common-java/blob/master/src/main/java/com/exasol/adapter/capabilities/LiteralCapability.java) | +| [Predicate Capabilities](capabilities_list.md#predicate-capabilities) | `FN_PRED_` | [PredicateCapability.java](https://github.com/exasol/virtual-schema-common-java/blob/master/src/main/java/com/exasol/adapter/capabilities/PredicateCapability.java) | +| [Scalar Function Capabilities](capabilities_list.md#scalar-function-capabilities) | `FN_` | [ScalarFunctionCapability.java](https://github.com/exasol/virtual-schema-common-java/blob/master/src/main/java/com/exasol/adapter/capabilities/ScalarFunctionCapability.java) | +| [Aggregate Function Capabilities](capabilities_list.md#aggregate-function-capabilities) | `FN_AGG_` | [AggregateFunctionCapability.java](https://github.com/exasol/virtual-schema-common-java/blob/master/src/main/java/com/exasol/adapter/capabilities/AggregateFunctionCapability.java)| ### Pushdown -Contains an abstract specification of what to be pushed down, and requests an pushdown SQL statement from the Adapter which can be used to retrieve the requested data. +Contains an abstract specification of what to be pushed down, and requests a pushdown SQL statement from the Adapter which can be used to retrieve the requested data. **Request:** @@ -395,6 +390,19 @@ will produce the following Request, assuming that the Adapter has all required c "numElements" : 10 } }, + "selectListDataTypes" : + [ + { + "precision" : 18, + "scale" : 0, + "type" : "DECIMAL" + }, + { + "precision" : 10, + "scale" : 0, + "type" : "DECIMAL" + } + ], "involvedTables": [ { "name" : "CLICKS", @@ -456,6 +464,8 @@ Notes * `orderBy`: The requested order-by clause, a list of `order_by_element` elements. * `limit` The requested limit of the result set, with an optional offset. * `involvedTables`: Metadata of the involved tables, encoded like in schemaMetadata. +* `selectListDataTypes`: List of data tyes expected in the result set. + This information is only provided by Exasol database with major version 8 and higher, see [Exasol Data Types API Documentation](data_types_api.md). **Response:** @@ -607,14 +617,14 @@ This element currently only occurs in from clause { "type": "join", "join_type": "inner", - "left": { - ... + "left": { + ... }, - "right" : { - ... + "right" : { + ... }, - "condition" : { - ... + "condition" : { + ... } } ``` diff --git a/doc/error_codes.md b/doc/error_codes.md deleted file mode 100644 index 923ea4d7..00000000 --- a/doc/error_codes.md +++ /dev/null @@ -1,3 +0,0 @@ -# Latest Used Error Codes - -E-VSCOMJAVA-32 \ No newline at end of file diff --git a/pk_generated_parent.pom b/pk_generated_parent.pom index fb41a732..d08ab75f 100644 --- a/pk_generated_parent.pom +++ b/pk_generated_parent.pom @@ -3,7 +3,7 @@ 4.0.0 com.exasol virtual-schema-common-java-generated-parent - 16.1.0 + 16.1.1 pom UTF-8 diff --git a/pom.xml b/pom.xml index b8a24137..96326cf3 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 virtual-schema-common-java - 16.1.0 + 16.1.1 Common module of Exasol Virtual Schemas Adapters This is one of the modules of Virtual Schemas Adapters. The libraries provided by this project are the foundation of the adapter development, i.e. adapters must be implemented on top of them. @@ -102,7 +102,7 @@ virtual-schema-common-java-generated-parent com.exasol - 16.1.0 + 16.1.1 pk_generated_parent.pom From 304b780f09870db57c48dfdaa0e40748b616943f Mon Sep 17 00:00:00 2001 From: KK Date: Tue, 13 Sep 2022 12:17:54 +0200 Subject: [PATCH 2/6] prepared release --- doc/changes/changelog.md | 1 - doc/changes/changes_16.1.0.md | 2 +- doc/changes/changes_16.1.1.md | 11 ----------- pk_generated_parent.pom | 2 +- pom.xml | 4 ++-- 5 files changed, 4 insertions(+), 16 deletions(-) delete mode 100644 doc/changes/changes_16.1.1.md diff --git a/doc/changes/changelog.md b/doc/changes/changelog.md index 0706084d..c231989b 100644 --- a/doc/changes/changelog.md +++ b/doc/changes/changelog.md @@ -1,6 +1,5 @@ # Changes -* [16.1.1](changes_16.1.1.md) * [16.1.0](changes_16.1.0.md) * [16.0.0](changes_16.0.0.md) * [15.3.3](changes_15.3.3.md) diff --git a/doc/changes/changes_16.1.0.md b/doc/changes/changes_16.1.0.md index a84cae0a..fc9b036d 100644 --- a/doc/changes/changes_16.1.0.md +++ b/doc/changes/changes_16.1.0.md @@ -1,4 +1,4 @@ -# Common module of Exasol Virtual Schemas Adapters 16.1.0, released 2022-09-12 +# Common module of Exasol Virtual Schemas Adapters 16.1.0, released 2022-09-13 Code name: Fixed data type properties diff --git a/doc/changes/changes_16.1.1.md b/doc/changes/changes_16.1.1.md deleted file mode 100644 index 19c9e1a2..00000000 --- a/doc/changes/changes_16.1.1.md +++ /dev/null @@ -1,11 +0,0 @@ -# Common module of Exasol Virtual Schemas Adapters 16.1.1, released 2022-09-13 - -Code name: Documentation Update - -## Summary - -Updated documentation. - -## Features - -* #255: Improved documentation diff --git a/pk_generated_parent.pom b/pk_generated_parent.pom index d08ab75f..fb41a732 100644 --- a/pk_generated_parent.pom +++ b/pk_generated_parent.pom @@ -3,7 +3,7 @@ 4.0.0 com.exasol virtual-schema-common-java-generated-parent - 16.1.1 + 16.1.0 pom UTF-8 diff --git a/pom.xml b/pom.xml index 96326cf3..b8a24137 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 virtual-schema-common-java - 16.1.1 + 16.1.0 Common module of Exasol Virtual Schemas Adapters This is one of the modules of Virtual Schemas Adapters. The libraries provided by this project are the foundation of the adapter development, i.e. adapters must be implemented on top of them. @@ -102,7 +102,7 @@ virtual-schema-common-java-generated-parent com.exasol - 16.1.1 + 16.1.0 pk_generated_parent.pom From 9a1e7a47eb6c017331e69597a49d39dfd905bb2c Mon Sep 17 00:00:00 2001 From: KK Date: Wed, 14 Sep 2022 18:30:54 +0200 Subject: [PATCH 3/6] #258 fixed --- doc/changes/changelog.md | 1 + doc/changes/changes_16.1.1.md | 10 ++++++++++ pk_generated_parent.pom | 2 +- pom.xml | 4 ++-- .../adapter/request/parser/RequestParser.java | 18 +++++++++--------- 5 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 doc/changes/changes_16.1.1.md diff --git a/doc/changes/changelog.md b/doc/changes/changelog.md index c231989b..0706084d 100644 --- a/doc/changes/changelog.md +++ b/doc/changes/changelog.md @@ -1,5 +1,6 @@ # Changes +* [16.1.1](changes_16.1.1.md) * [16.1.0](changes_16.1.0.md) * [16.0.0](changes_16.0.0.md) * [15.3.3](changes_15.3.3.md) diff --git a/doc/changes/changes_16.1.1.md b/doc/changes/changes_16.1.1.md new file mode 100644 index 00000000..be9b4759 --- /dev/null +++ b/doc/changes/changes_16.1.1.md @@ -0,0 +1,10 @@ +# Common module of Exasol Virtual Schemas Adapters 16.1.1, released 2022-??-?? + +Code name: + +## Summary + +## Features + +* ISSUE_NUMBER: description + diff --git a/pk_generated_parent.pom b/pk_generated_parent.pom index fb41a732..d08ab75f 100644 --- a/pk_generated_parent.pom +++ b/pk_generated_parent.pom @@ -3,7 +3,7 @@ 4.0.0 com.exasol virtual-schema-common-java-generated-parent - 16.1.0 + 16.1.1 pom UTF-8 diff --git a/pom.xml b/pom.xml index b8a24137..96326cf3 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 virtual-schema-common-java - 16.1.0 + 16.1.1 Common module of Exasol Virtual Schemas Adapters This is one of the modules of Virtual Schemas Adapters. The libraries provided by this project are the foundation of the adapter development, i.e. adapters must be implemented on top of them. @@ -102,7 +102,7 @@ virtual-schema-common-java-generated-parent com.exasol - 16.1.0 + 16.1.1 pk_generated_parent.pom diff --git a/src/main/java/com/exasol/adapter/request/parser/RequestParser.java b/src/main/java/com/exasol/adapter/request/parser/RequestParser.java index e068a93a..14c77eb4 100644 --- a/src/main/java/com/exasol/adapter/request/parser/RequestParser.java +++ b/src/main/java/com/exasol/adapter/request/parser/RequestParser.java @@ -71,12 +71,19 @@ private AbstractAdapterRequest parseRefreshRequest(final JsonObject root, final } private AbstractAdapterRequest parsePushdownRequest(final JsonObject root, final SchemaMetadataInfo metadataInfo) { - final SqlStatement statement = parsePushdownStatement(root); + final JsonObject pushdownJson = root.getJsonObject(PUSHDOW_REQUEST_KEY); final List involvedTables = parseInvolvedTables(root); - final List dataTypes = parseDataTypes(root); + final SqlStatement statement = parsePushdownStatement(pushdownJson, involvedTables); + final List dataTypes = parseDataTypes(pushdownJson); return new PushDownRequest(metadataInfo, statement, involvedTables, dataTypes); } + private SqlStatement parsePushdownStatement(final JsonObject pushdownJson, + final List involvedTables) { + final PushdownSqlParser pushdownSqlParser = PushdownSqlParser.createWithTablesMetadata(involvedTables); + return (SqlStatement) pushdownSqlParser.parseExpression(pushdownJson); + } + private List parseDataTypes(final JsonObject root) { if (!root.containsKey(SELECT_LIST_DATATYPES_KEY)) { return Collections.emptyList(); @@ -102,13 +109,6 @@ private SchemaMetadataInfo readSchemaMetadataInfo(final JsonObject root) { } } - private SqlStatement parsePushdownStatement(final JsonObject root) { - final List involvedTables = parseInvolvedTables(root); - final PushdownSqlParser pushdownSqlParser = PushdownSqlParser.createWithTablesMetadata(involvedTables); - final JsonObject jsonPushdownStatement = root.getJsonObject(PUSHDOW_REQUEST_KEY); - return (SqlStatement) pushdownSqlParser.parseExpression(jsonPushdownStatement); - } - /** * Create a {@link RequestParser} * From 92559cb0c5e07394adf12816521124faf0706f90 Mon Sep 17 00:00:00 2001 From: KK Date: Wed, 14 Sep 2022 18:35:22 +0200 Subject: [PATCH 4/6] changelog --- doc/changes/changes_16.1.1.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/changes/changes_16.1.1.md b/doc/changes/changes_16.1.1.md index 19c9e1a2..9bea1964 100644 --- a/doc/changes/changes_16.1.1.md +++ b/doc/changes/changes_16.1.1.md @@ -1,11 +1,15 @@ # Common module of Exasol Virtual Schemas Adapters 16.1.1, released 2022-09-13 -Code name: Documentation Update +Code name: Fixed data type properties and Documentation Update ## Summary -Updated documentation. +Fixed data type properties and updated documentation. ## Features * #255: Improved documentation + +## Bug Fixes + +* #258: Fixed data type properties From a240734ee97b29ad59f3c307a593d44fbcdac762 Mon Sep 17 00:00:00 2001 From: KK Date: Wed, 14 Sep 2022 19:05:20 +0200 Subject: [PATCH 5/6] ported tests to run on windows, too --- .../request/parser/RequestParserTest.java | 35 +++++++++++-------- .../exasol/logging/CompactFormatterTest.java | 24 ++++++------- .../exasol/logging/RemoteLogManagerTest.java | 31 ++++++++++++---- 3 files changed, 56 insertions(+), 34 deletions(-) diff --git a/src/test/java/com/exasol/adapter/request/parser/RequestParserTest.java b/src/test/java/com/exasol/adapter/request/parser/RequestParserTest.java index 9fb04a62..25d4abab 100644 --- a/src/test/java/com/exasol/adapter/request/parser/RequestParserTest.java +++ b/src/test/java/com/exasol/adapter/request/parser/RequestParserTest.java @@ -1,6 +1,7 @@ package com.exasol.adapter.request.parser; import static com.exasol.adapter.request.parser.json.builder.JsonEntry.*; +import static com.exasol.adapter.request.parser.json.builder.JsonEntry.array; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.hamcrest.collection.IsMapContaining.hasEntry; @@ -18,6 +19,7 @@ import com.exasol.adapter.metadata.TableMetadata; import com.exasol.adapter.request.*; import com.exasol.adapter.request.parser.json.builder.*; +import com.exasol.adapter.request.parser.json.builder.JsonParent.JsonObject; class RequestParserTest { private static final JsonKeyValue SCHEMA_METADATA_INFO = JsonEntry.entry("schemaMetadataInfo", @@ -76,7 +78,7 @@ void unsupportedPropertyType() { @Test void classicPushDownRequest() { - final AdapterRequest request = this.parser.parse(createPushDownRequest().render()); + final AdapterRequest request = this.parser.parse(createPushDownRequest(null).render()); assertThat("Request class", request, instanceOf(PushDownRequest.class)); final List involvedTables = ((PushDownRequest) request).getInvolvedTablesMetadata(); final List selectListDataTypes = ((PushDownRequest) request).getSelectListDataTypes(); @@ -88,13 +90,12 @@ void classicPushDownRequest() { @Test void pushDownRequestWithSelectListDataTypes() { - final String rawRequest = createPushDownRequest().addChild( // - entry("selectListDataTypes", array( // - object(entry("type", "DECIMAL"), // - entry("precision", 9), // - entry("scale", 10)), // - object(entry("type", "DOUBLE"))))) // - .render(); + final JsonKeyValue ltdt = entry("selectListDataTypes", array( // + object(entry("type", "DECIMAL"), // + entry("precision", 9), // + entry("scale", 10)), // + object(entry("type", "DOUBLE")))); // + final String rawRequest = createPushDownRequest(ltdt).render(); final AdapterRequest request = this.parser.parse(rawRequest); final List selectListDataTypes = ((PushDownRequest) request).getSelectListDataTypes(); assertAll(() -> assertThat(request.getType(), equalTo(AdapterRequestType.PUSHDOWN)), @@ -132,15 +133,19 @@ void requestWithoutSchemaMetadata() { assertThat(request.getVirtualSchemaName(), equalTo("UNKNOWN")); } - private JsonParent createPushDownRequest() { + private JsonParent createPushDownRequest(final JsonEntry selectListDataTypes) { + final JsonObject pdr = object( // + entry("type", "select"), // + entry("from", object( // + entry("name", "FOO"), // + entry("type", "table") // + ))); + if (selectListDataTypes != null) { + pdr.addChild(selectListDataTypes); + } return JsonEntry.object( // entry("type", "pushdown"), // - entry("pushdownRequest", object( // - entry("type", "select"), // - entry("from", object( // - entry("name", "FOO"), // - entry("type", "table") // - )))), // + entry("pushdownRequest", pdr), // entry("involvedTables", array(object( // entry("name", "FOO"), // entry("columns", array(object( // diff --git a/src/test/java/com/exasol/logging/CompactFormatterTest.java b/src/test/java/com/exasol/logging/CompactFormatterTest.java index 1af87461..80e4e8e4 100644 --- a/src/test/java/com/exasol/logging/CompactFormatterTest.java +++ b/src/test/java/com/exasol/logging/CompactFormatterTest.java @@ -1,8 +1,9 @@ package com.exasol.logging; +import static com.exasol.logging.RemoteLogManagerTest.*; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.text.MatchesPattern.matchesPattern; -import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; import java.util.logging.Level; @@ -14,7 +15,6 @@ class CompactFormatterTest { private LogRecord record; private final CompactFormatter formatter = new CompactFormatter(); - private final String TIMESTAMP_PATTERN = "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3}"; @BeforeEach void beforeEach() { @@ -24,51 +24,49 @@ void beforeEach() { @Test void testFormat() { final String formattedRecord = this.formatter.format(this.record); - assertThat(formattedRecord, matchesPattern(this.TIMESTAMP_PATTERN + " SEVERE +message\\n")); + assertThat(formattedRecord, matchesTimeStamp(" SEVERE +message")); } @Test void testFormatWithEmptyClass() { this.record.setSourceClassName(""); final String formattedRecord = this.formatter.format(this.record); - assertThat(formattedRecord, matchesPattern(this.TIMESTAMP_PATTERN + " SEVERE +message\\n")); + assertThat(formattedRecord, matchesTimeStamp(" SEVERE +message")); } @Test void testFormatWithSimpleClass() { this.record.setSourceClassName("example"); final String formattedRecord = this.formatter.format(this.record); - assertThat(formattedRecord, matchesPattern(this.TIMESTAMP_PATTERN + " SEVERE +\\[example\\] +message\\n")); + assertThat(formattedRecord, matchesTimeStamp(" SEVERE +\\[example\\] +message")); } @Test void testFormatWithFullClass() { this.record.setSourceClassName("com.exasol.example"); final String formattedRecord = this.formatter.format(this.record); - assertThat(formattedRecord, - matchesPattern(this.TIMESTAMP_PATTERN + " SEVERE +\\[c\\.e\\.example\\] +message\\n")); + assertThat(formattedRecord, matchesTimeStamp(" SEVERE +\\[c\\.e\\.example\\] +message")); } @Test void testFormatRobustAgainstDoubleDot() { this.record.setSourceClassName("com.exasol..example"); final String formattedRecord = this.formatter.format(this.record); - assertThat(formattedRecord, - matchesPattern(this.TIMESTAMP_PATTERN + " SEVERE +\\[c\\.e\\.\\.example\\] +message\\n")); + assertThat(formattedRecord, matchesTimeStamp(" SEVERE +\\[c\\.e\\.\\.example\\] +message")); } @Test void testFormatRobustAgainstEndDot() { this.record.setSourceClassName("com.exasol."); final String formattedRecord = this.formatter.format(this.record); - assertThat(formattedRecord, matchesPattern(this.TIMESTAMP_PATTERN + " SEVERE +\\[c\\.e\\.\\] +message\\n")); + assertThat(formattedRecord, matchesTimeStamp(" SEVERE +\\[c\\.e\\.\\] +message")); } @Test void testFormatRobustAgainstOnlyDot() { this.record.setSourceClassName("."); final String formattedRecord = this.formatter.format(this.record); - assertThat(formattedRecord, matchesPattern(this.TIMESTAMP_PATTERN + " SEVERE +\\[\\.\\] +message\\n")); + assertThat(formattedRecord, matchesTimeStamp(" SEVERE +\\[\\.\\] +message")); } @Test @@ -76,7 +74,7 @@ void testFormatWithPlaceholders() { final LogRecord recordWithPlaceholders = new LogRecord(Level.SEVERE, "message {0} : {1}"); recordWithPlaceholders.setParameters(new String[] { "foo", "bar" }); final String formattedRecord = this.formatter.format(recordWithPlaceholders); - assertThat(formattedRecord, matchesPattern(this.TIMESTAMP_PATTERN + " SEVERE +message foo : bar\\n")); + assertThat(formattedRecord, matchesTimeStamp(" SEVERE +message foo : bar")); } @Test @@ -88,7 +86,7 @@ void testFormatException() { final String formattedRecord = this.formatter.format(this.record); assertAll( () -> assertThat(formattedRecord, - matchesPattern(this.TIMESTAMP_PATTERN + " SEVERE the message(\\n.*)*")), + matchesPattern(TIMESTAMP_PATTERN + " SEVERE the message\\n(.*" + LINEFEED_PATTERN + ")*")), () -> assertThat(formattedRecord, containsString("the exception")), () -> assertThat(formattedRecord, containsString("the cause"))); } diff --git a/src/test/java/com/exasol/logging/RemoteLogManagerTest.java b/src/test/java/com/exasol/logging/RemoteLogManagerTest.java index 5f33ed9b..7e5899a8 100644 --- a/src/test/java/com/exasol/logging/RemoteLogManagerTest.java +++ b/src/test/java/com/exasol/logging/RemoteLogManagerTest.java @@ -1,13 +1,14 @@ package com.exasol.logging; -import static org.hamcrest.Matchers.matchesPattern; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.matchesPattern; import java.io.*; import java.net.*; import java.util.logging.Level; import java.util.logging.Logger; +import org.hamcrest.Matcher; import org.itsallcode.io.Capturable; import org.itsallcode.junit.sysextensions.SystemErrGuard; import org.junit.jupiter.api.*; @@ -15,11 +16,30 @@ @ExtendWith(SystemErrGuard.class) class RemoteLogManagerTest { + private static final String CLASS_TAG = "\\[c\\.e\\.l\\.RemoteLogManagerTest\\]"; - private static final String TIMESTAMP_PATTERN = "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3}"; + static final String TIMESTAMP_PATTERN = "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3}"; private static final Logger LOGGER = Logger.getLogger(RemoteLogManagerTest.class.getName()); + static final String LINEFEED_PATTERN = linefeedPattern(); + + static Matcher matchesTimeStamp(final String content) { + return matchesPattern(TIMESTAMP_PATTERN + content + LINEFEED_PATTERN); + } + private RemoteLogManager logManager; + static String linefeedPattern() { + switch (System.lineSeparator()) { + case "\r\n": + return "\\r\\n"; + case "\r": + return "\\r"; + case "\n": // falling through intentionally + default: + return "\\n"; + } + } + @BeforeEach void BeforeEach() { this.logManager = new RemoteLogManager(); @@ -35,7 +55,7 @@ void testSetupConsoleLogging(final Capturable stream) throws IOException { this.logManager.setupConsoleLogger(Level.INFO); stream.capture(); LOGGER.info("Hello."); - assertThat(stream.getCapturedData(), matchesPattern(TIMESTAMP_PATTERN + " INFO +" + CLASS_TAG + " Hello.\\n")); + assertThat(stream.getCapturedData(), matchesTimeStamp(" INFO +" + CLASS_TAG + " Hello.")); } @Test @@ -43,8 +63,7 @@ void testSetupConsoleLoggingWithMoreDetailedLogLevel(final Capturable stream) th this.logManager.setupConsoleLogger(Level.ALL); stream.capture(); LOGGER.finest(() -> "Hello."); - assertThat(stream.getCapturedData(), - matchesPattern(TIMESTAMP_PATTERN + " FINEST +" + CLASS_TAG + " Hello.\\n")); + assertThat(stream.getCapturedData(), matchesTimeStamp(" FINEST +" + CLASS_TAG + " Hello.")); } @Test @@ -103,6 +122,6 @@ private String readLogMessageFromSocket(final Socket socket) throws IOException void testFallBackFromRemoteLoggingToConsoleLogging(final Capturable stream) { stream.capture(); this.logManager.setupRemoteLogger("this.hostname.should.not.exist.exasol.com", 3000, Level.ALL); - assertThat(stream.getCapturedData(), matchesPattern(".*Falling back to console log.\n")); + assertThat(stream.getCapturedData(), matchesPattern(".*Falling back to console log." + System.lineSeparator())); } } \ No newline at end of file From 1e7ad587a0e8b1cec437efc4e9cc2cbfda65d1ed Mon Sep 17 00:00:00 2001 From: KK Date: Wed, 14 Sep 2022 19:14:24 +0200 Subject: [PATCH 6/6] set release date to tomorrow --- doc/changes/changes_16.1.1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes/changes_16.1.1.md b/doc/changes/changes_16.1.1.md index 9bea1964..243aba86 100644 --- a/doc/changes/changes_16.1.1.md +++ b/doc/changes/changes_16.1.1.md @@ -1,4 +1,4 @@ -# Common module of Exasol Virtual Schemas Adapters 16.1.1, released 2022-09-13 +# Common module of Exasol Virtual Schemas Adapters 16.1.1, released 2022-09-15 Code name: Fixed data type properties and Documentation Update