Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ingestion: Added form in Big Query type to edit the queries. #5431

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ const ActorTag = styled(Tag)`
`;

export const ExpandedActor = ({ actor, popOver, closable, onClose }: Props) => {
console.log(actor);

const entityRegistry = useEntityRegistry();

let name = '';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button, Checkbox, Form, Input, Tooltip } from 'antd';
import React from 'react';
import { Button, Checkbox, Form, Input, Select, Tooltip } from 'antd';
import styled from 'styled-components/macro';
import { MinusCircleOutlined, PlusOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { FieldType, RecipeField } from './utils';
Expand All @@ -25,6 +25,10 @@ const StyledRemoveIcon = styled(MinusCircleOutlined)`
margin-left: 10px;
`;

const StyledSelectField = styled(Select)`
margin-left: 10px;
`;

const StyledFormItem = styled(Form.Item)<{ alignLeft: boolean; removeMargin: boolean }>`
margin-bottom: ${(props) => (props.removeMargin ? '0' : '16px')};

Expand Down Expand Up @@ -52,6 +56,10 @@ interface ListFieldProps {
removeMargin?: boolean;
}

interface SelectFieldProps {
field: RecipeField;
}

function ListField({ field, removeMargin }: ListFieldProps) {
return (
<Form.List name={field.name}>
Expand Down Expand Up @@ -80,6 +88,25 @@ function ListField({ field, removeMargin }: ListFieldProps) {
);
}

function SelectField({ field }: SelectFieldProps) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you make it so that the select dropdown and the label are on the same line? instead of the selector being on a second line right now. And can you also make the selector not quite so wide? so like width: 80%;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked and fixed.

return (
<Form.Item
name={field.name}
label={field.label}
tooltip={field.tooltip}
style={{ flexDirection: 'row', width: '80%', display: 'flex', alignItems: 'baseline' }}
>
{field.options && (
<StyledSelectField>
{field.options.map((option) => (
<Select.Option value={option.value}>{option.label}</Select.Option>
))}
</StyledSelectField>
)}
</Form.Item>
);
}

interface Props {
field: RecipeField;
removeMargin?: boolean;
Expand All @@ -90,6 +117,8 @@ function FormField(props: Props) {

if (field.type === FieldType.LIST) return <ListField field={field} removeMargin={removeMargin} />;

if (field.type === FieldType.SELECT) return <SelectField field={field} />;

const isBoolean = field.type === FieldType.BOOLEAN;
const input = isBoolean ? <Checkbox /> : <Input />;
const valuePropName = isBoolean ? 'checked' : 'value';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
import React from 'react';
import { set, get } from 'lodash';
import { SNOWFLAKE } from '../../conf/snowflake/snowflake';
import { BIGQUERY } from '../../conf/bigquery/bigquery';
import { REDSHIFT } from '../../conf/redshift/redshift';

export enum FieldType {
TEXT,
BOOLEAN,
LIST,
SELECT,
}

interface Option {
label: string;
value: string;
}

export interface RecipeField {
name: string;
label: string;
tooltip: string;
tooltip: string | React.ReactNode;
type: FieldType;
fieldPath: string;
rules: any[] | null;
section?: string;
options?: Option[];
getValueFromRecipeOverride?: (recipe: any) => any;
setValueOnRecipeOverride?: (recipe: any, value: any) => any;
}
Expand Down Expand Up @@ -102,6 +112,96 @@ export const SNOWFLAKE_ROLE: RecipeField = {
rules: null,
};

export const BIGQUERY_PROJECT_ID: RecipeField = {
name: 'project_id',
label: 'BigQuery Project ID',
tooltip: 'Project ID where you have rights to run queries and create tables.',
type: FieldType.TEXT,
fieldPath: 'source.config.project_id',
rules: null,
};

export const BIGQUERY_CREDENTIAL_PROJECT_ID: RecipeField = {
name: 'credential.project_id',
label: 'Credentials Project ID',
tooltip: 'Project id to set the credentials.',
type: FieldType.TEXT,
fieldPath: 'source.config.credential.project_id',
rules: null,
};

export const BIGQUERY_PRIVATE_KEY_ID: RecipeField = {
name: 'credential.private_key_id',
label: 'Private Key Id',
tooltip: 'Private key id.',
type: FieldType.TEXT,
fieldPath: 'source.config.credential.private_key_id',
rules: null,
};

export const BIGQUERY_PRIVATE_KEY: RecipeField = {
name: 'credential.private_key',
label: 'Private Key',
tooltip: 'Private key in a form of "-----BEGIN PRIVATE KEY-----\nprivate-key\n-----END PRIVATE KEY-----\n".',
type: FieldType.TEXT,
fieldPath: 'source.config.credential.private_key',
rules: null,
};

export const BIGQUERY_CLIENT_EMAIL: RecipeField = {
name: 'credential.client_email',
label: 'Client Email',
tooltip: 'Client email.',
type: FieldType.TEXT,
fieldPath: 'source.config.credential.client_email',
rules: null,
};

export const BIGQUERY_CLIENT_ID: RecipeField = {
name: 'credential.client_id',
label: 'Client ID',
tooltip: 'Client ID.',
type: FieldType.TEXT,
fieldPath: 'source.config.credential.client_id',
rules: null,
};

export const REDSHIFT_HOST_PORT: RecipeField = {
name: 'host_port',
label: 'Host Port',
tooltip: 'Host URL.',
type: FieldType.TEXT,
fieldPath: 'source.config.host_port',
rules: null,
};

export const REDSHIFT_DATABASE: RecipeField = {
name: 'database',
label: 'Database',
tooltip: 'Database (catalog).',
type: FieldType.TEXT,
fieldPath: 'source.config.database',
rules: null,
};

export const REDSHIFT_USERNAME: RecipeField = {
name: 'redshift.username',
label: 'Redshift username',
tooltip: 'Username',
type: FieldType.TEXT,
fieldPath: 'source.config.username',
rules: null,
};

export const REDSHIFT_PASSWORD: RecipeField = {
name: 'redshift.password',
label: 'Redshift password',
tooltip: 'Password',
type: FieldType.TEXT,
fieldPath: 'source.config.password',
rules: null,
};

const includeLineageFieldPathA = 'source.config.include_table_lineage';
const includeLineageFieldPathB = 'source.config.include_view_lineage';
export const INCLUDE_LINEAGE: RecipeField = {
Expand Down Expand Up @@ -157,6 +257,47 @@ export const STATEFUL_INGESTION_ENABLED: RecipeField = {
rules: null,
};

export const UPSTREAM_LINEAGE_IN_REPORT: RecipeField = {
name: 'upstream_lineage_in_report',
label: 'Include Upstream Lineage In Report.',
tooltip: 'Useful for debugging lineage information. Set to True to see the raw lineage created internally.',
type: FieldType.BOOLEAN,
fieldPath: 'source.config.upstream_lineage_in_report',
rules: null,
};

const TableLineageModeTooltip = () => {
return (
<div>
<p>
Which table lineage collector mode to use. Check out{' '}
<a
href="https://datahubproject.io/docs/generated/ingestion/sources/redshift/#config-details"
target="_blank"
rel="noreferrer"
>
the documentation
</a>{' '}
explaining the difference between the three available modes.
</p>
</div>
);
};

export const TABLE_LINEAGE_MODE: RecipeField = {
name: 'table_lineage_mode',
label: 'Table Lineage Mode',
tooltip: TableLineageModeTooltip,
type: FieldType.SELECT,
fieldPath: 'source.config.table_lineage_mode',
rules: null,
options: [
{ label: 'stl_scan_based', value: 'stl_scan_based' },
{ label: 'sql_based', value: 'sql_based' },
{ label: 'mixed', value: 'mixed' },
],
};

const databaseAllowFieldPath = 'source.config.database_pattern.allow';
export const DATABASE_ALLOW: RecipeField = {
name: 'database_pattern.allow',
Expand Down Expand Up @@ -282,6 +423,23 @@ export const RECIPE_FIELDS = {
VIEW_DENY,
],
},
[BIGQUERY]: {
fields: [
BIGQUERY_PROJECT_ID,
BIGQUERY_CREDENTIAL_PROJECT_ID,
BIGQUERY_PRIVATE_KEY,
BIGQUERY_PRIVATE_KEY_ID,
BIGQUERY_CLIENT_EMAIL,
BIGQUERY_CLIENT_ID,
],
advancedFields: [INCLUDE_LINEAGE, PROFILING_ENABLED, STATEFUL_INGESTION_ENABLED, UPSTREAM_LINEAGE_IN_REPORT],
filterFields: [TABLE_ALLOW, TABLE_DENY, SCHEMA_ALLOW, SCHEMA_DENY, VIEW_ALLOW, VIEW_DENY],
},
[REDSHIFT]: {
fields: [REDSHIFT_HOST_PORT, REDSHIFT_DATABASE, REDSHIFT_USERNAME, REDSHIFT_PASSWORD],
advancedFields: [INCLUDE_LINEAGE, PROFILING_ENABLED, STATEFUL_INGESTION_ENABLED, TABLE_LINEAGE_MODE],
filterFields: [TABLE_ALLOW, TABLE_DENY, SCHEMA_ALLOW, SCHEMA_DENY, VIEW_ALLOW, VIEW_DENY],
},
};

export const CONNECTORS_WITH_FORM = new Set(Object.keys(RECIPE_FIELDS));
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ source:
client_id: # Your BQ client id, e.g. "123456678890"
`;

export const BIGQUERY = 'bigquery';

const bigqueryConfig: SourceConfig = {
type: 'bigquery',
type: BIGQUERY,
Comment on lines +24 to +27
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Contributor Author

@Ankit-Keshari-Vituity Ankit-Keshari-Vituity Jul 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you:)

placeholderRecipe,
displayName: 'BigQuery',
docsUrl: 'https://datahubproject.io/docs/generated/ingestion/sources/bigquery/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ source:
enabled: false
`;

export const REDSHIFT = 'redshift';

const redshiftConfig: SourceConfig = {
type: 'redshift',
type: REDSHIFT,
placeholderRecipe,
displayName: 'Redshift',
docsUrl: 'https://datahubproject.io/docs/generated/ingestion/sources/redshift/',
Expand Down