Skip to content

Commit c2ccc91

Browse files
authored
Catalog to Datasource changes (#1027) (#1049)
Signed-off-by: vamsi-amazon <[email protected]> (cherry picked from commit 3e30379)
1 parent 2ec975a commit c2ccc91

File tree

20 files changed

+159
-159
lines changed

20 files changed

+159
-159
lines changed

core/src/main/java/org/opensearch/sql/planner/physical/catalog/CatalogTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
/**
24-
* Table implementation to handle show catalogs command.
24+
* Table implementation to handle show datasources command.
2525
* Since catalog information is not tied to any storage engine, this info
2626
* is handled via Catalog Table.
2727
*

core/src/main/java/org/opensearch/sql/planner/physical/catalog/CatalogTableScan.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void open() {
5151
for (Catalog catalog : catalogs) {
5252
exprValues.add(
5353
new ExprTupleValue(new LinkedHashMap<>(ImmutableMap.of(
54-
"CATALOG_NAME", ExprValueUtils.stringValue(catalog.getName()),
54+
"DATASOURCE_NAME", ExprValueUtils.stringValue(catalog.getName()),
5555
"CONNECTOR_TYPE", ExprValueUtils.stringValue(catalog.getConnectorType().name())))));
5656
}
5757
iterator = exprValues.iterator();

core/src/main/java/org/opensearch/sql/planner/physical/catalog/CatalogTableSchema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public enum CatalogTableSchema {
2222

2323
CATALOG_TABLE_SCHEMA(new LinkedHashMap<>() {
2424
{
25-
put("CATALOG_NAME", STRING);
25+
put("DATASOURCE_NAME", STRING);
2626
put("CONNECTOR_TYPE", STRING);
2727
}
2828
}

core/src/test/java/org/opensearch/sql/planner/physical/catalog/CatalogTableScanTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void testIterator() {
6161
assertTrue(catalogTableScan.hasNext());
6262
for (Catalog catalog : catalogSet) {
6363
assertEquals(new ExprTupleValue(new LinkedHashMap<>(ImmutableMap.of(
64-
"CATALOG_NAME", ExprValueUtils.stringValue(catalog.getName()),
64+
"DATASOURCE_NAME", ExprValueUtils.stringValue(catalog.getName()),
6565
"CONNECTOR_TYPE", ExprValueUtils.stringValue(catalog.getConnectorType().name())))),
6666
catalogTableScan.next());
6767
}

core/src/test/java/org/opensearch/sql/planner/physical/catalog/CatalogTableTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void testGetFieldTypes() {
3333
CatalogTable catalogTable = new CatalogTable(catalogService);
3434
Map<String, ExprType> fieldTypes = catalogTable.getFieldTypes();
3535
Map<String, ExprType> expectedTypes = new HashMap<>();
36-
expectedTypes.put("CATALOG_NAME", ExprCoreType.STRING);
36+
expectedTypes.put("DATASOURCE_NAME", ExprCoreType.STRING);
3737
expectedTypes.put("CONNECTOR_TYPE", ExprCoreType.STRING);
3838
assertEquals(expectedTypes, fieldTypes);
3939
}

docs/category.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"user/ppl/cmd/ad.rst",
1111
"user/ppl/cmd/dedup.rst",
1212
"user/ppl/cmd/describe.rst",
13-
"user/ppl/cmd/showcatalogs.rst",
13+
"user/ppl/cmd/showdatasources.rst",
1414
"user/ppl/cmd/information_schema.rst",
1515
"user/ppl/cmd/eval.rst",
1616
"user/ppl/cmd/fields.rst",

docs/user/general/identifiers.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,18 @@ Fully Qualified Table Names
184184

185185
Description
186186
-----------
187-
With the introduction of different datasource catalogs along with Opensearch, support for fully qualified table names became compulsory to resolve tables to a catalog.
187+
With the introduction of different datasources along with Opensearch, support for fully qualified table names became compulsory to resolve tables to a datasource.
188188

189189
Format for fully qualified table name.
190-
``<catalogName>.<schemaName>.<tableName>``
190+
``<datasourceName>.<schemaName>.<tableName>``
191191

192-
* catalogName:[Mandatory] Catalog information is mandatory when querying over tables from catalogs other than opensearch connector.
192+
* datasourceName:[Mandatory] Datasource information is mandatory when querying over tables from datasources other than opensearch connector.
193193

194194
* schemaName:[Optional] Schema is a logical abstraction for a group of tables. In the current state, we only support ``default`` and ``information_schema``. Any schema mentioned in the fully qualified name other than these two will be resolved to be part of tableName.
195195

196196
* tableName:[Mandatory] tableName is mandatory.
197197

198-
The current resolution algorithm works in such a way, the old queries on opensearch work without specifying any catalog name.
198+
The current resolution algorithm works in such a way, the old queries on opensearch work without specifying any datasource name.
199199
So queries on opensearch indices doesn't need a fully qualified table name.
200200

201201
Table Name Resolution Algorithm.
@@ -205,24 +205,24 @@ Fully qualified Name is divided into parts based on ``.`` character.
205205

206206
TableName resolution algorithm works in the following manner.
207207

208-
1. Take the first part of the qualified name and resolve it to a catalog from the list of catalogs configured.
209-
If it doesn't resolve to any of the catalog names configured, catalog name will default to ``@opensearch`` catalog.
208+
1. Take the first part of the qualified name and resolve it to a datasource from the list of datasources configured.
209+
If it doesn't resolve to any of the datasource names configured, datasource name will default to ``@opensearch`` datasource.
210210

211-
2. Take the first part of the remaining qualified name after capturing the catalog name.
212-
If this part represents any of the supported schemas under catalog, it will resolve to the same otherwise schema name will resolve to ``default`` schema.
211+
2. Take the first part of the remaining qualified name after capturing the datasource name.
212+
If this part represents any of the supported schemas under datasource, it will resolve to the same otherwise schema name will resolve to ``default`` schema.
213213
Currently ``default`` and ``information_schema`` are the only schemas supported.
214214

215215
3. Rest of the parts are combined to resolve tablename.
216216

217-
** Only table name identifiers are supported with fully qualified names, identifiers used for columns and other attributes doesn't require prefixing with catalog and schema information.**
217+
** Only table name identifiers are supported with fully qualified names, identifiers used for columns and other attributes doesn't require prefixing with datasource and schema information.**
218218

219219
Examples
220220
--------
221-
Assume [my_prometheus] is the only catalog configured other than default opensearch engine.
221+
Assume [my_prometheus] is the only datasource configured other than default opensearch engine.
222222

223223
1. ``my_prometheus.default.http_requests_total``
224224

225-
catalogName = ``my_prometheus`` [Is in the list of catalogs configured].
225+
datasourceName = ``my_prometheus`` [Is in the list of datasources configured].
226226

227227
schemaName = ``default`` [Is in the list of schemas supported].
228228

@@ -231,7 +231,7 @@ tableName = ``http_requests_total``.
231231
2. ``logs.12.13.1``
232232

233233

234-
catalogName = ``@opensearch`` [Resolves to default @opensearch connector since [my_prometheus] is the only catalog configured name.]
234+
datasourceName = ``@opensearch`` [Resolves to default @opensearch connector since [my_prometheus] is the only catalog configured name.]
235235

236236
schemaName = ``default`` [No supported schema found, so default to `default`].
237237

@@ -241,23 +241,23 @@ tableName = ``logs.12.13.1``.
241241
3. ``my_prometheus.http_requests_total``
242242

243243

244-
catalogName = ```my_prometheus`` [Is in the list of catalogs configured].
244+
datasourceName = ```my_prometheus`` [Is in the list of datasources configured].
245245

246246
schemaName = ``default`` [No supported schema found, so default to `default`].
247247

248248
tableName = ``http_requests_total``.
249249

250250
4. ``prometheus.http_requests_total``
251251

252-
catalogName = ``@opensearch`` [Resolves to default @opensearch connector since [my_prometheus] is the only catalog configured name.]
252+
datasourceName = ``@opensearch`` [Resolves to default @opensearch connector since [my_prometheus] is the only datasource configured name.]
253253

254254
schemaName = ``default`` [No supported schema found, so default to `default`].
255255

256256
tableName = ``prometheus.http_requests_total``.
257257

258258
5. ``prometheus.default.http_requests_total.1.2.3``
259259

260-
catalogName = ``@opensearch`` [Resolves to default @opensearch connector since [my_prometheus] is the only catalog configured name.]
260+
datasourceName = ``@opensearch`` [Resolves to default @opensearch connector since [my_prometheus] is the only catalog configured name.]
261261

262262
schemaName = ``default`` [No supported schema found, so default to `default`].
263263

docs/user/ppl/admin/catalog.rst

Lines changed: 0 additions & 83 deletions
This file was deleted.

docs/user/ppl/admin/datasources.rst

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
.. highlight:: sh
2+
3+
===================
4+
Datasource Settings
5+
===================
6+
7+
.. rubric:: Table of contents
8+
9+
.. contents::
10+
:local:
11+
:depth: 1
12+
13+
Introduction
14+
============
15+
16+
The concept of ``datasource`` is introduced to support the federation of SQL/PPL query engine to multiple data stores.
17+
This helps PPL users to leverage data from multiple data stores and derive correlation and insights.
18+
Datasource definition provides the information to connect to a data store and also gives a name to them to refer in PPL commands.
19+
20+
21+
Definitions of datasource and connector
22+
====================================
23+
* Connector is a component that adapts the query engine to a datastore. For example, Prometheus connector would adapt and help execute the queries to run on Prometheus datastore. connector name is enough in the datasource definition json.
24+
* Datasource is a construct to define how to connect to a data store and which connector to adapt by query engine.
25+
26+
Example Prometheus Datasource Definition ::
27+
28+
[{
29+
"name" : "my_prometheus",
30+
"connector": "prometheus",
31+
"properties" : {
32+
"prometheus.uri" : "http://localhost:8080",
33+
"prometheus.auth.type" : "basicauth",
34+
"prometheus.auth.username" : "admin",
35+
"prometheus.auth.password" : "admin"
36+
}
37+
}]
38+
Datasource configuration Restrictions.
39+
40+
* ``name``, ``connector``, ``properties`` are required fields in the datasource configuration.
41+
* All the datasource names should be unique and match the following regex[``[@*A-Za-z]+?[*a-zA-Z_\-0-9]*``].
42+
* Allowed Connectors.
43+
* ``prometheus`` [More details: `Prometheus Connector <prometheus_connector.rst>`_]
44+
* All the allowed config parameters in ``properties`` are defined in individual connector pages mentioned above.
45+
46+
Configuring a datasource in OpenSearch
47+
======================================
48+
49+
* Datasources are configured in opensearch keystore as secure settings under ``plugins.query.federation.datasources.config`` key as they contain credential info.
50+
* A json file containing array of datasource configurations should be injected into keystore with the above mentioned key. sample json file can be seen in the above section.
51+
52+
53+
[**To be run on all the nodes in the cluster**] Command to add datasources.json file to OpenSearch Keystore ::
54+
55+
>> bin/opensearch-keystore add-file plugins.query.federation.datasource.config datasources.json
56+
57+
Datasources can be configured during opensearch start up or can be updated while the opensearch is running.
58+
If we update a datasource configuration during runtime, the following api should be triggered to update the query engine with the latest changes.
59+
60+
[**Required only if we update keystore settings during runtime**] Secure Settings refresh api::
61+
62+
>> curl --request POST \
63+
--url http://{{opensearch-domain}}:9200/_nodes/reload_secure_settings \
64+
--data '{"secure_settings_password":"{{keystore-password}}"}'
65+
66+
67+
Using a datasource in PPL command
68+
====================================
69+
Datasource is referred in source command as show in the code block below.
70+
Based on the abstraction designed by the connector,
71+
one can refer the corresponding entity as table in the source command.
72+
For example in prometheus connector, each metric is abstracted as a table.
73+
so we can refer a metric and apply stats over it in the following way.
74+
75+
Example source command with prometheus datasource ::
76+
77+
>> source = my_prometheus.prometheus_http_requests_total | stats avg(@value) by job;
78+
79+
80+
Limitations of datasource
81+
====================================
82+
Datasource settings are global and users with PPL access are allowed to fetch data from all the defined datasources.
83+
PPL access can be controlled using roles.(More details: `Security Settings <security.rst>`_)

docs/user/ppl/cmd/information_schema.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ Metadata queries using information_schema
1111

1212
Description
1313
============
14-
| Use ``information_schema`` in source command to query tables information under a catalog.
14+
| Use ``information_schema`` in source command to query tables information under a datasource.
1515
In the current state, ``information_schema`` only support metadata of tables.
1616
This schema will be extended for views, columns and other metadata info in future.
1717

1818

1919
Syntax
2020
============
21-
source = catalog.information_schema.tables;
21+
source = datasource.information_schema.tables;
2222

23-
Example 1: Fetch tables in prometheus catalog.
23+
Example 1: Fetch tables in prometheus datasource.
2424
==============================================
2525

26-
The examples fetches tables in the prometheus catalog.
26+
The examples fetches tables in the prometheus datasource.
2727

2828
PPL query for fetching PROMETHEUS TABLES with where clause::
2929

@@ -36,10 +36,10 @@ PPL query for fetching PROMETHEUS TABLES with where clause::
3636
+-----------------+----------------+--------------------------------+--------------+--------+---------------------------+
3737

3838

39-
Example 2: Search tables in prometheus catalog.
40-
===============================================
39+
Example 2: Search tables in prometheus datasource.
40+
=================================================
4141

42-
The examples searches tables in the prometheus catalog.
42+
The examples searches tables in the prometheus datasource.
4343

4444
PPL query for searching PROMETHEUS TABLES::
4545

docs/user/ppl/cmd/showcatalogs.rst

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)