diff --git a/common/constants/index.ts b/common/constants/index.ts new file mode 100644 index 00000000..4fc24444 --- /dev/null +++ b/common/constants/index.ts @@ -0,0 +1,82 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export const PLUGIN_ID = 'queryWorkbenchDashboards'; +export const PLUGIN_NAME = 'Query Workbench'; +export const OPENSEARCH_ACC_DOCUMENTATION_URL = 'https://opensearch.org/docs/latest'; +export const ACC_INDEX_TYPE_DOCUMENTATION_URL = 'https://opensearch.org/docs/latest'; + +export const SKIPPING_INDEX = `skipping_index` +export const ON_LOAD_QUERY = `SHOW tables LIKE '%';`; +export const SKIPPING_INDEX_QUERY = `CREATE SKIPPING INDEX ON myS3.logs_db.http_logs +(status VALUE_SET) +WITH ( + auto_refresh = true + )` +export const COVERING_INDEX_QUERY =`CREATE INDEX covering_idx ON myS3.logs_db.http_logs + (status) + WITH ( + auto_refresh = true + )` +export const CREATE_DATABASE_QUERY =`CREATE DATABASE myS3.logs_db` +export const CREATE_TABLE_QUERY =`CREATE EXTERNAL TABLE logs ( + key BIGINT, + status INTEGER, + size FLOAT, + agent STRING, + timestamp DATE +) +USING JSON +OPTIONS ( + path 's3://test/path', + compression 'gzip' +);` + +export const ACCELERATION_INDEX_TYPES = [ + { label: 'Skipping Index', value: 'skipping' }, + { label: 'Covering Index', value: 'covering' }, + // { label: 'Materialized View', value: 'materialized' }, Hidden Option -> Until opensearch-spark feature is ready +]; + +export const ACCELERATION_AGGREGRATION_FUNCTIONS = [ + { label: 'count' }, + { label: 'sum' }, + { label: 'avg' }, + { label: 'max' }, + { label: 'min' }, +]; + +export const ACCELERATION_TIME_INTERVAL = [ + { text: 'millisecond(s)', value: 'millisecond' }, + { text: 'second(s)', value: 'second' }, + { text: 'hour(s)', value: 'hour' }, + { text: 'day(s)', value: 'day' }, + { text: 'week(s)', value: 'week' }, +]; + +export const SKIPPING_INDEX_ACCELERATION_METHODS = [ + { value: 'PARTITION', text: 'Partition' }, + { value: 'VALUE_SET', text: 'Value Set' }, + { value: 'MIN_MAX', text: 'Min Max' }, +]; + +export const ACCELERATION_ADD_FIELDS_TEXT = '(add fields here)'; +export const ACCELERATION_INDEX_NAME_REGEX = /^[a-z][a-z_\-]*$/; +export const ACCELERATION_S3_URL_REGEX = /^(s3|s3a):\/\/[a-zA-Z0-9.\-]+\/.*/; +export const ACCELERATION_DEFUALT_SKIPPING_INDEX_NAME = 'skipping'; + +export const ACCELERATION_INDEX_NAME_INFO = `All OpenSearch acceleration indices have a naming format of pattern: \`prefix__suffix\`. They share a common prefix structure, which is \`flint____\`. Additionally, they may have a suffix that varies based on the index type. +##### Skipping Index +- For 'Skipping' indices, a fixed index name 'skipping' is used, and this name cannot be modified by the user. The suffix added to this type is \`_index\`. + - An example of a 'Skipping' index name would be: \`flint_mydatasource_mydb_mytable_skipping_index\`. +##### Covering Index +- 'Covering' indices allow users to specify their index name. The suffix added to this type is \`_index\`. + - For instance, a 'Covering' index name could be: \`flint_mydatasource_mydb_mytable_myindexname_index\`. +##### Materialized View Index +- 'Materialized View' indices also enable users to define their index name, but they do not have a suffix. + - An example of a 'Materialized View' index name might look like: \`flint_mydatasource_mydb_mytable_myindexname\`. +##### Note: +- All user given index names must be in lowercase letters. Cannot begin with underscores or hyphens. Spaces, commas, and characters :, ", *, +, /, \, |, ?, #, >, or < are not allowed. + `; diff --git a/common/index.ts b/common/index.ts deleted file mode 100644 index a3d39b17..00000000 --- a/common/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - - -export const PLUGIN_ID = 'queryWorkbenchDashboards'; -export const PLUGIN_NAME = 'Query Workbench'; diff --git a/common/types/index.ts b/common/types/index.ts new file mode 100644 index 00000000..c96bb147 --- /dev/null +++ b/common/types/index.ts @@ -0,0 +1,80 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export type AggregationFunctionType = 'count' | 'sum' | 'avg' | 'max' | 'min'; + +export interface MaterializedViewColumn { + id: string; + functionName: AggregationFunctionType; + functionParam: string; + fieldAlias?: string; +} + +export type SkippingIndexAccMethodType = 'PARTITION' | 'VALUE_SET' | 'MIN_MAX'; + +export interface SkippingIndexRowType { + id: string; + fieldName: string; + dataType: string; + accelerationMethod: SkippingIndexAccMethodType; +} + +export interface DataTableFieldsType { + id: string; + fieldName: string; + dataType: string; +} + +export interface RefreshIntervalType { + refreshWindow: number; + refreshInterval: string; +} + +export type AccelerationIndexType = 'skipping' | 'covering' | 'materialized'; + +export interface GroupByTumbleType { + timeField: string; + tumbleWindow: number; + tumbleInterval: string; +} + +export interface materializedViewQueryType { + columnsValues: MaterializedViewColumn[]; + groupByTumbleValue: GroupByTumbleType; +} + +export interface FormErrorsType { + dataSourceError: string[]; + databaseError: string[]; + dataTableError: string[]; + skippingIndexError: string[]; + coveringIndexError: string[]; + materializedViewError: string[]; + indexNameError: string[]; + primaryShardsError: string[]; + replicaShardsError: string[]; + refreshIntervalError: string[]; + checkpointLocationError: string[]; +} + +export interface CreateAccelerationForm { + dataSource: string; + database: string; + dataTable: string; + dataTableFields: DataTableFieldsType[]; + accelerationIndexType: AccelerationIndexType; + skippingIndexQueryData: SkippingIndexRowType[]; + coveringIndexQueryData: string[]; + materializedViewQueryData: materializedViewQueryType; + accelerationIndexName: string; + primaryShardsCount: number; + replicaShardsCount: number; + refreshType: 'interval' | 'auto'; + checkpointLocation: string | undefined; + refreshIntervalOptions: RefreshIntervalType; + formErrors: FormErrorsType; +} + +export type AsyncQueryLoadingStatus = "SUCCESS" | "FAILED" | "RUNNING" | "SCHEDULED" | "CANCELED" \ No newline at end of file diff --git a/package.json b/package.json index 7d0de23a..1a3f5174 100644 --- a/package.json +++ b/package.json @@ -27,35 +27,23 @@ }, "devDependencies": { "@testing-library/user-event": "^13.1.9", - "@types/hapi-latest": "npm:@types/hapi@18.0.7", - "@types/react-router-dom": "^5.3.2", + "@types/enzyme-adapter-react-16": "^1.0.6", + "@types/react-test-renderer": "^16.9.1", "cypress": "^5.0.0", "eslint": "^6.8.0", - "eslint-plugin-no-unsanitized": "^3.0.2", - "eslint-plugin-prefer-object-spread": "^1.2.1", "husky": "^4.2.5", "jest-raw-loader": "^1.0.1", "lint-staged": "^10.2.0", "mutationobserver-shim": "^0.3.3", - "ts-jest": "^26.1.0", - "ts-node": "^8.9.1", - "tslint": "^6.1.2", - "tslint-config-prettier": "^1.18.0", - "tslint-plugin-prettier": "^2.0.1" + "jest-dom": "^4.0.0", + "ts-jest": "^29.1.0" }, "resolutions": { - "**/@types/node": "^10.12.27", - "@types/react": "^16.3.14", - "**/@types/angular": "^1.6.50", - "**/@types/jest": "^24.0.9", - "**/@types/react-dom": "^16.0.5", - "**/@types/react-router-dom": "^4.3.1", + "ansi-regex": "^5.0.1", "eslint-utils": "^2.0.0", "json-schema": "^0.4.0", - "**/@types/react": "^16.3.14", - "ansi-regex": "^5.0.1", "yaml": "^2.2.2", "tough-cookie": "^4.1.3", "semver": "^7.5.2" } -} \ No newline at end of file +} diff --git a/public/ace-themes/sql_console.js b/public/ace-themes/sql_console.js index c841db28..b0d4898c 100644 --- a/public/ace-themes/sql_console.js +++ b/public/ace-themes/sql_console.js @@ -3,10 +3,13 @@ * SPDX-License-Identifier: Apache-2.0 */ - import * as ace from 'brace'; -ace.define('ace/theme/sql_console', ['require', 'exports', 'module', 'ace/lib/dom'], function (acequire, exports, module) { +ace.define('ace/theme/sql_console', ['require', 'exports', 'module', 'ace/lib/dom'], function ( + acequire, + exports, + module +) { exports.isDark = false; exports.cssClass = 'ace-sql-console'; exports.cssText = require('../index.scss'); diff --git a/public/components/Main/__snapshots__/main.test.tsx.snap b/public/components/Main/__snapshots__/main.test.tsx.snap index 6730126f..ff0dd051 100644 --- a/public/components/Main/__snapshots__/main.test.tsx.snap +++ b/public/components/Main/__snapshots__/main.test.tsx.snap @@ -2,106 +2,67 @@ exports[`
spec click clear button 1`] = `
-
+
+ Data Sources +
+
-
+
+
+
+ + query-language-swtich +
-
-

- Query editor -

-
-
+ + + + SQL + + + + +
+
+
+ +
+
+
+
+
- -
-