Skip to content

Commit

Permalink
Web console: Fix segment re-ingest (apache#8454)
Browse files Browse the repository at this point in the history
* fixing ingest spec

* rm console.log

* ingest segment spec

* make sure step query always being run

* better example interface

* add keywords

* placeholders

* do not overwrite datasource name in data loader spec

* fix comment typo
  • Loading branch information
vogievetsky authored and clintropolis committed Sep 3, 2019
1 parent abd8646 commit 637a9e8
Show file tree
Hide file tree
Showing 52 changed files with 755 additions and 390 deletions.
8 changes: 7 additions & 1 deletion web-console/lib/keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,10 @@ exports.SQL_EXPRESSION_PARTS = [

exports.SQL_CONSTANTS = ['NULL', 'FALSE', 'TRUE'];

exports.SQL_DYNAMICS = ['CURRENT_TIMESTAMP', 'CURRENT_DATE'];
exports.SQL_DYNAMICS = [
'CURRENT_TIMESTAMP',
'CURRENT_DATE',
'LOCALTIME',
'LOCALTIMESTAMP',
'CURRENT_TIME',
];
47 changes: 33 additions & 14 deletions web-console/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web-console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"d3": "^5.10.1",
"d3-array": "^2.3.1",
"druid-console": "0.0.2",
"druid-query-toolkit": "^0.3.26",
"druid-query-toolkit": "^0.3.27",
"file-saver": "^2.0.2",
"has-own-prop": "^2.0.0",
"hjson": "^3.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
*/

import React from 'react';
import ReactTable, { Column } from 'react-table';
import ReactTable from 'react-table';

import { Loader } from '..';
import { queryDruidSql, QueryManager } from '../../utils';
import { ColumnMetadata } from '../../utils/column-metadata';
import { Loader } from '../loader/loader';

import './datasource-columns-table.scss';

interface TableRow {
columnsName: string;
columnName: string;
columnType: string;
}

Expand All @@ -36,7 +36,7 @@ export interface DatasourceColumnsTableProps {
}

export interface DatasourceColumnsTableState {
columns?: any;
columns?: TableRow[];
loading: boolean;
error?: string;
}
Expand All @@ -45,24 +45,26 @@ export class DatasourceColumnsTable extends React.PureComponent<
DatasourceColumnsTableProps,
DatasourceColumnsTableState
> {
private supervisorStatisticsTableQueryManager: QueryManager<null, TableRow[]>;
private datasourceColumnsQueryManager: QueryManager<null, TableRow[]>;

constructor(props: DatasourceColumnsTableProps, context: any) {
super(props, context);
this.state = {
loading: true,
};
this.supervisorStatisticsTableQueryManager = new QueryManager({

this.datasourceColumnsQueryManager = new QueryManager({
processQuery: async () => {
const { datasourceId } = this.props;

const resp = await queryDruidSql<ColumnMetadata>({
query: `SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'druid' AND TABLE_NAME = '${datasourceId}'`,
});
const dimensionArray = resp.map(object => {
return { columnsName: object.COLUMN_NAME, columnType: object.DATA_TYPE };

return resp.map(object => {
return { columnName: object.COLUMN_NAME, columnType: object.DATA_TYPE };
});
return dimensionArray;
},
onStateChange: ({ result, error, loading }) => {
this.setState({ columns: result, error, loading });
Expand All @@ -71,30 +73,28 @@ export class DatasourceColumnsTable extends React.PureComponent<
}

componentDidMount(): void {
this.supervisorStatisticsTableQueryManager.runQuery(null);
this.datasourceColumnsQueryManager.runQuery(null);
}

renderTable(error?: string) {
const { columns } = this.state;
console.log(columns);
const tableColumns: Column<TableRow>[] = [
{
Header: 'Column Name',
accessor: 'columnsName',
},
{
Header: 'Data Type',
accessor: 'columnType',
},
];

return (
<ReactTable
data={this.state.columns ? this.state.columns : []}
showPagination={false}
defaultPageSize={15}
columns={tableColumns}
noDataText={error ? error : 'No statistics data found'}
data={columns || []}
defaultPageSize={20}
filterable
columns={[
{
Header: 'Column name',
accessor: 'columnName',
},
{
Header: 'Data type',
accessor: 'columnType',
},
]}
noDataText={error ? error : 'No column data found'}
/>
);
}
Expand Down
8 changes: 4 additions & 4 deletions web-console/src/components/json-input/json-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import React from 'react';
import AceEditor from 'react-ace';

import { parseStringToJSON, stringifyJSON, validJson } from '../../utils';
import { parseStringToJson, stringifyJson, validJson } from '../../utils';

interface JSONInputProps {
onChange: (newJSONValue: any) => void;
Expand All @@ -45,7 +45,7 @@ export class JSONInput extends React.PureComponent<JSONInputProps, JSONInputStat

componentDidMount(): void {
const { value } = this.props;
const stringValue = stringifyJSON(value);
const stringValue = stringifyJson(value);
this.setState({
stringValue,
});
Expand All @@ -54,7 +54,7 @@ export class JSONInput extends React.PureComponent<JSONInputProps, JSONInputStat
componentWillReceiveProps(nextProps: JSONInputProps): void {
if (JSON.stringify(nextProps.value) !== JSON.stringify(this.props.value)) {
this.setState({
stringValue: stringifyJSON(nextProps.value),
stringValue: stringifyJson(nextProps.value),
});
}
}
Expand All @@ -70,7 +70,7 @@ export class JSONInput extends React.PureComponent<JSONInputProps, JSONInputStat
name="ace-editor"
onChange={(e: string) => {
this.setState({ stringValue: e });
if (validJson(e) || e === '') onChange(parseStringToJSON(e));
if (validJson(e) || e === '') onChange(parseStringToJson(e));
if (updateInputValidity) updateInputValidity(validJson(e) || e === '');
}}
focus={focus}
Expand Down
2 changes: 2 additions & 0 deletions web-console/src/components/rule-editor/rule-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ export class RuleEditor extends React.PureComponent<RuleEditorProps, RuleEditorS
onChange={(e: any) =>
onChange(RuleEditor.changePeriod(rule, e.target.value as any))
}
placeholder="P1D"
/>
)}
{ruleTimeType === 'ByInterval' && (
Expand All @@ -303,6 +304,7 @@ export class RuleEditor extends React.PureComponent<RuleEditorProps, RuleEditorS
onChange={(e: any) =>
onChange(RuleEditor.changeInterval(rule, e.target.value as any))
}
placeholder="2010-01-01/2020-01-01"
/>
)}
</ControlGroup>
Expand Down
2 changes: 1 addition & 1 deletion web-console/src/components/show-json/show-json.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class ShowJson extends React.PureComponent<ShowJsonProps, ShowJsonState>
onClick={() => {
copy(jsonValue ? jsonValue : '', { format: 'text/plain' });
AppToaster.show({
message: 'JSON copied to clipboard',
message: 'JSON value copied to clipboard',
intent: Intent.SUCCESS,
});
}}
Expand Down
Loading

0 comments on commit 637a9e8

Please sign in to comment.