diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DatasetDetails/DatasetDetails.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/DatasetDetails/DatasetDetails.interface.ts
index 4b423b8815f..da71acba5c0 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/DatasetDetails/DatasetDetails.interface.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/components/DatasetDetails/DatasetDetails.interface.ts
@@ -46,7 +46,6 @@ export interface DatasetDetailsProps {
owner: EntityReference;
description: string;
tableProfile: Table['profile'];
- tableQueries: Table['tableQueries'];
columns: Column[];
tier: TagLabel;
sampleData: TableData;
@@ -57,7 +56,6 @@ export interface DatasetDetailsProps {
deleted?: boolean;
isTableProfileLoading?: boolean;
isSampleDataLoading?: boolean;
- isQueriesLoading?: boolean;
isentityThreadLoading: boolean;
feedCount: number;
entityFieldThreadCount: EntityFieldThreadCount[];
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/TableSummary/TableSummary.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/TableSummary/TableSummary.component.tsx
index 946b3d1ce6e..839c57ef619 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/TableSummary/TableSummary.component.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/TableSummary/TableSummary.component.tsx
@@ -27,10 +27,7 @@ import {
} from 'react';
import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
-import {
- getLatestTableProfileByFqn,
- getTableQueryByTableId,
-} from 'rest/tableAPI';
+import { getLatestTableProfileByFqn } from 'rest/tableAPI';
import { getListTestCase } from 'rest/testAPI';
import {
DRAWER_NAVIGATION_OPTIONS,
@@ -115,15 +112,9 @@ function TableSummary({
const { profile, tableConstraints } = profileResponse;
- const queriesResponse = await getTableQueryByTableId(
- entityDetails.id || ''
- );
-
- const { tableQueries } = queriesResponse;
-
setTableDetails((prev) => {
if (prev) {
- return { ...prev, profile, tableQueries, tableConstraints };
+ return { ...prev, profile, tableConstraints };
} else {
return {} as Table;
}
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/mocks/TableSummary.mock.ts b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/mocks/TableSummary.mock.ts
index f5e31684412..333dfb0852f 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/mocks/TableSummary.mock.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/mocks/TableSummary.mock.ts
@@ -20,8 +20,6 @@ import {
TagSource,
} from '../../../../generated/entity/data/table';
-const mockDate = new Date('2023-01-03');
-
export const mockTableEntityDetails: Table = {
id: '8dd1f238-6ba0-46c6-a091-7db81f2a6bed',
name: 'dim.api/client',
@@ -79,24 +77,6 @@ export const mockTableEntityDetails: Table = {
state: State.Confirmed,
},
],
- tableQueries: [
- {
- query:
- 'select cust.customer_id, fact_order.order_id from dim_customer cust join fact_order on',
- users: [],
- vote: 1,
- checksum: 'ff727cf70d5a7a9810704532f3571b82',
- queryDate: mockDate,
- },
- {
- query:
- 'select sale.sale_id, cust.customer_id, fact_order.order_ir from shopify.',
- users: [],
- vote: 1,
- checksum: 'e14e02c387dd8482d10c4ec7d3d4c69a',
- queryDate: mockDate,
- },
- ],
service: {
id: '0875717c-5855-427c-8dd6-92d4cbfe7c51',
type: 'databaseService',
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/QueryCard.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/QueryCard.test.tsx
index 9af9d48a63b..68f43762152 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/QueryCard.test.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/QueryCard.test.tsx
@@ -14,10 +14,10 @@
import {
findByTestId,
findByText,
- // getByTestId,
queryByTestId,
render,
} from '@testing-library/react';
+import { Query } from 'generated/entity/data/query';
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import QueryCard from './QueryCard';
@@ -36,7 +36,7 @@ const mockQueryData = {
],
vote: 1,
checksum: '0232b0368458aadb29230ccc531462c9',
-};
+} as Query;
jest.mock('../schema-editor/SchemaEditor', () => {
return jest.fn().mockReturnValue(
SchemaEditor
);
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/QueryCard.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/QueryCard.tsx
index 0b37f902c6b..4e0a995ada0 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/QueryCard.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/QueryCard.tsx
@@ -12,17 +12,17 @@
*/
import classNames from 'classnames';
+import { Query } from 'generated/entity/data/query';
// import { isUndefined } from 'lodash';
import React, { FC, HTMLAttributes, useState } from 'react';
// import { Link } from 'react-router-dom';
// import { getUserPath } from '../../constants/constants';
import { CSMode } from '../../enums/codemirror.enum';
-import { SQLQuery } from '../../generated/entity/data/table';
import SVGIcons, { Icons } from '../../utils/SvgUtils';
import CopyToClipboardButton from '../buttons/CopyToClipboardButton/CopyToClipboardButton';
import SchemaEditor from '../schema-editor/SchemaEditor';
interface QueryCardProp extends HTMLAttributes {
- query: SQLQuery;
+ query: Query;
}
const QueryCard: FC = ({ className, query }) => {
const [expanded, setExpanded] = useState(false);
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/TableQueries.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/TableQueries.test.tsx
index 94f6ef98695..f04c05ff66d 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/TableQueries.test.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/TableQueries.test.tsx
@@ -19,7 +19,7 @@ import {
} from '@testing-library/react';
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
-import { MOCK_TABLE } from '../../mocks/TableData.mock';
+import { MOCK_TABLE_QUERY } from '../../mocks/TableData.mock';
import TableQueries from './TableQueries';
const mockTableQueriesProp = {
@@ -29,10 +29,10 @@ const mockTableQueriesProp = {
jest.mock('./QueryCard', () => {
return jest.fn().mockReturnValue(QueryCard
);
});
-jest.mock('rest/tableAPI', () => ({
- getTableQueryByTableId: jest
+jest.mock('rest/queryAPI', () => ({
+ getQueriesList: jest
.fn()
- .mockImplementation(() => Promise.resolve(MOCK_TABLE)),
+ .mockImplementation(() => Promise.resolve({ data: MOCK_TABLE_QUERY })),
}));
describe('Test TableQueries Component', () => {
@@ -46,7 +46,7 @@ describe('Test TableQueries Component', () => {
});
it('Check if TableQueries component has n query card', async () => {
- const queriesLength = MOCK_TABLE.tableQueries?.length || 0;
+ const queriesLength = MOCK_TABLE_QUERY?.length || 0;
const { container } = render(, {
wrapper: MemoryRouter,
});
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/TableQueries.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/TableQueries.tsx
index d37abd83166..14423dddfe9 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/TableQueries.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/TableQueries/TableQueries.tsx
@@ -13,10 +13,10 @@
import { Col, Row } from 'antd';
import { AxiosError } from 'axios';
+import { Query } from 'generated/entity/data/query';
import { isEmpty } from 'lodash';
import React, { FC, useEffect, useState } from 'react';
-import { getTableQueryByTableId } from 'rest/tableAPI';
-import { Table } from '../../generated/entity/data/table';
+import { getQueriesList } from 'rest/queryAPI';
import { withLoader } from '../../hoc/withLoader';
import { showErrorToast } from '../../utils/ToastUtils';
import ErrorPlaceHolder from '../common/error-with-placeholder/ErrorPlaceHolder';
@@ -32,13 +32,13 @@ const TableQueries: FC = ({
isTableDeleted,
tableId,
}: TableQueriesProp) => {
- const [tableQueries, setTableQueries] = useState([]);
+ const [tableQueries, setTableQueries] = useState([]);
const [isQueriesLoading, setIsQueriesLoading] = useState(true);
const fetchTableQuery = async () => {
try {
- const queries = await getTableQueryByTableId(tableId);
- setTableQueries(queries.tableQueries ?? []);
+ const queries = await getQueriesList({ entityId: tableId });
+ setTableQueries(queries.data);
} catch (error) {
showErrorToast(error as AxiosError);
} finally {
diff --git a/openmetadata-ui/src/main/resources/ui/src/constants/elasticsearch.constant.ts b/openmetadata-ui/src/main/resources/ui/src/constants/elasticsearch.constant.ts
index 0330e8ed4da..c40dd3708e5 100644
--- a/openmetadata-ui/src/main/resources/ui/src/constants/elasticsearch.constant.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/constants/elasticsearch.constant.ts
@@ -98,7 +98,6 @@ export const RECREATE_INDEX_OPTIONS = [
},
];
-
export const ENTITY_TREE_OPTIONS = [
{
title: 'All',
@@ -114,7 +113,10 @@ export const ENTITY_TREE_OPTIONS = [
},
];
-export const RE_INDEX_LANG_OPTIONS = map(SearchIndexMappingLanguage, (value) => ({
- label: value,
- value,
-}));
\ No newline at end of file
+export const RE_INDEX_LANG_OPTIONS = map(
+ SearchIndexMappingLanguage,
+ (value) => ({
+ label: value,
+ value,
+ })
+);
diff --git a/openmetadata-ui/src/main/resources/ui/src/mocks/TableData.mock.ts b/openmetadata-ui/src/main/resources/ui/src/mocks/TableData.mock.ts
index 8a608705d32..0e5ab41a374 100644
--- a/openmetadata-ui/src/main/resources/ui/src/mocks/TableData.mock.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/mocks/TableData.mock.ts
@@ -191,14 +191,6 @@ export const MOCK_TABLE = {
columnCount: 12,
rowCount: 14567,
},
- tableQueries: [
- {
- query:
- 'create table shopify.dim_address_clean as select address_id, shop_id, first_name, last_name, address1 as address, company, city, region, zip, country, phone from shopify.dim_address',
- vote: 1,
- checksum: 'cd59a9d0d0b8a245f7382264afac8bdc',
- },
- ],
sampleData: {
columns: ['address_id', 'shop_id', 'first_name', 'last_name'],
rows: [
@@ -331,3 +323,12 @@ export const COLUMN_PROFILER_RESULT = [
median: 7344.0,
},
];
+
+export const MOCK_TABLE_QUERY = [
+ {
+ query:
+ 'create table shopify.dim_address_clean as select address_id, shop_id, first_name, last_name, address1 as address, company, city, region, zip, country, phone from shopify.dim_address',
+ vote: 1,
+ checksum: 'cd59a9d0d0b8a245f7382264afac8bdc',
+ },
+];
diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/DatasetDetailsPage/DatasetDetailsPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/DatasetDetailsPage/DatasetDetailsPage.component.tsx
index febcf22ecfe..4d4a63bcee2 100644
--- a/openmetadata-ui/src/main/resources/ui/src/pages/DatasetDetailsPage/DatasetDetailsPage.component.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/pages/DatasetDetailsPage/DatasetDetailsPage.component.tsx
@@ -91,8 +91,6 @@ const DatasetDetailsPage: FunctionComponent = () => {
const [isLoading, setIsLoading] = useState(true);
const [isSampleDataLoading, setIsSampleDataLoading] =
useState(false);
- const [isTableQueriesLoading, setIsTableQueriesLoading] =
- useState(false);
const [isentityThreadLoading, setIsentityThreadLoading] =
useState(false);
const [isTableProfileLoading, setIsTableProfileLoading] =
@@ -137,7 +135,6 @@ const DatasetDetailsPage: FunctionComponent = () => {
);
const [deleted, setDeleted] = useState(false);
const [isError, setIsError] = useState(false);
- const [tableQueries, setTableQueries] = useState([]);
const [entityThread, setEntityThread] = useState([]);
const [feedCount, setFeedCount] = useState(0);
@@ -398,33 +395,6 @@ const DatasetDetailsPage: FunctionComponent = () => {
break;
}
- case TabSpecificField.TABLE_QUERIES: {
- if ((tableQueries?.length ?? 0) > 0) {
- break;
- } else {
- setIsTableQueriesLoading(true);
- getTableDetailsByFQN(tableFQN, tabField)
- .then((res) => {
- if (res) {
- const { tableQueries } = res;
- setTableQueries(tableQueries);
- } else {
- showErrorToast(
- jsonData['api-error-messages']['fetch-table-queries-error']
- );
- }
- })
- .catch((err: AxiosError) => {
- showErrorToast(
- err,
- jsonData['api-error-messages']['fetch-table-queries-error']
- );
- })
- .finally(() => setIsTableQueriesLoading(false));
-
- break;
- }
- }
case TabSpecificField.ACTIVITY_FEED: {
getFeedData();
@@ -748,7 +718,6 @@ const DatasetDetailsPage: FunctionComponent = () => {
followTableHandler={followTable}
followers={followers}
handleExtensionUpdate={handleExtentionUpdate}
- isQueriesLoading={isTableQueriesLoading}
isSampleDataLoading={isSampleDataLoading}
isTableProfileLoading={isTableProfileLoading}
isentityThreadLoading={isentityThreadLoading}
@@ -762,7 +731,6 @@ const DatasetDetailsPage: FunctionComponent = () => {
slashedTableName={slashedTableName}
tableDetails={tableDetails}
tableProfile={tableProfile}
- tableQueries={tableQueries}
tableTags={tableTags}
tableType={tableType}
tagUpdateHandler={onTagUpdate}
diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/ElasticSearchIndexPage/ElasticSearchReIndexModal.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/ElasticSearchIndexPage/ElasticSearchReIndexModal.component.tsx
index 3e9890375e8..f66d12fe1b5 100644
--- a/openmetadata-ui/src/main/resources/ui/src/pages/ElasticSearchIndexPage/ElasticSearchReIndexModal.component.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/pages/ElasticSearchIndexPage/ElasticSearchReIndexModal.component.tsx
@@ -12,15 +12,13 @@
*/
import { Form, Input, Modal, Select, TreeSelect } from 'antd';
-import { SearchIndexMappingLanguage } from 'generated/configuration/elasticSearchConfiguration';
-import { map } from 'lodash';
import React from 'react';
import { useTranslation } from 'react-i18next';
import {
ELASTIC_SEARCH_INITIAL_VALUES,
- RECREATE_INDEX_OPTIONS,
ENTITY_TREE_OPTIONS,
- RE_INDEX_LANG_OPTIONS
+ RECREATE_INDEX_OPTIONS,
+ RE_INDEX_LANG_OPTIONS,
} from '../../constants/elasticsearch.constant';
import { CreateEventPublisherJob } from '../../generated/api/createEventPublisherJob';
@@ -39,8 +37,6 @@ const ReIndexAllModal = ({
}: ReIndexAllModalInterface) => {
const { t } = useTranslation();
-
-
return (
{
tableProfile={
mockDatasetData.tableProfile as unknown as Table['profile']
}
- tableQueries={[]}
tableTags={mockDatasetData.tableTags}
tableType={mockDatasetData.tableType as TableType}
tagUpdateHandler={handleCountChange}
diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/queryAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/queryAPI.ts
new file mode 100644
index 00000000000..90ed94ba201
--- /dev/null
+++ b/openmetadata-ui/src/main/resources/ui/src/rest/queryAPI.ts
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2022 Collate.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AxiosResponse } from 'axios';
+import { CreateQuery } from 'generated/api/data/createQuery';
+import { Query } from 'generated/entity/data/query';
+import { Include } from 'generated/type/include';
+import { PagingResponse } from 'Models';
+import APIClient from './index';
+
+type Params = {
+ fields?: string;
+ limit?: number;
+ before?: string;
+ after?: string;
+ include?: Include;
+};
+
+export type ListQueriesParams = Params & {
+ entityId?: string;
+};
+
+const BASE_URL = '/queries';
+
+export const getQueriesList = async (params?: ListQueriesParams) => {
+ const response = await APIClient.get>(BASE_URL, {
+ params,
+ });
+
+ return response.data;
+};
+export const postQuery = async (query: CreateQuery) => {
+ const response = await APIClient.post>(
+ BASE_URL,
+ query
+ );
+
+ return response.data;
+};
diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/tableAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/tableAPI.ts
index b298a3c6938..1e2d4ed388f 100644
--- a/openmetadata-ui/src/main/resources/ui/src/rest/tableAPI.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/rest/tableAPI.ts
@@ -218,12 +218,6 @@ export const getSampleDataByTableId = async (id: string) => {
return response.data;
};
-export const getTableQueryByTableId = async (id: string) => {
- const response = await APIClient.get(`/tables/${id}/tableQuery`);
-
- return response.data;
-};
-
export const getLatestTableProfileByFqn = async (fqn: string) => {
const encodedFQN = encodeURIComponent(fqn);
const response = await APIClient.get