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

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
@@ -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 Down Expand Up @@ -52,6 +52,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 +84,30 @@ 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={
<Label>
{field.label}
<Tooltip overlay={field.tooltip}>
<StyledQuestion />
</Tooltip>
</Label>
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

here you can actually just let ant design do this work for you! so you can just pass in label={field.label} and tooltip={field.tooltip}

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.

>
{field.tableLineages && (
<Select>
{field.tableLineages.map((lineage) => (
<Select.Option value={lineage.value}>{lineage.label}</Select.Option>
))}
</Select>
)}
</Form.Item>
);
}

interface Props {
field: RecipeField;
removeMargin?: boolean;
Expand All @@ -90,6 +118,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
145 changes: 145 additions & 0 deletions datahub-web-react/src/app/ingest/source/builder/RecipeForm/utils.ts
@@ -1,10 +1,18 @@
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 LineageType {
label: string;
value: string;
}

export interface RecipeField {
Expand All @@ -15,6 +23,7 @@ export interface RecipeField {
fieldPath: string;
rules: any[] | null;
section?: string;
tableLineages?: LineageType[];
Copy link
Collaborator

Choose a reason for hiding this comment

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

in order to make this more generalizable let's name this field options instead of tableLineages for when we have other select types. Same thing goes with changing the type from LineageType -> Option

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.

getValueFromRecipeOverride?: (recipe: any) => any;
setValueOnRecipeOverride?: (recipe: any, value: any) => any;
}
Expand Down Expand Up @@ -102,6 +111,97 @@ export const SNOWFLAKE_ROLE: RecipeField = {
rules: null,
};

export const BIGQUERY_PROJECT_ID: RecipeField = {
name: 'project_id',
label: 'BigQuery Project ID',
tooltip:
'Project ID to ingest usage from. If not specified, will infer from environment. Deprecated in favour of projects.',
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm where did you get this description? Let's change it to just be "Project ID where you have rights to run queries and create tables."

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.

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: 'Username',
tooltip: 'Username',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know the docs just say "Username" but maybe let's change to "Redshift username"

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.

type: FieldType.TEXT,
fieldPath: 'source.config.username',
rules: null,
};

export const REDSHIFT_PASSWORD: RecipeField = {
name: 'redshift.password',
label: 'Password',
tooltip: 'Password',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar here - "Reshift password"

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.

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,29 @@ export const STATEFUL_INGESTION_ENABLED: RecipeField = {
rules: null,
};

export const INCLUDE_UPSTREAM_LINEAGE_IN_REPORT: RecipeField = {
name: 'include_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.include_upstream_lineage_in_report',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe the name and resulting fieldpath should just be upstream_lineage_in_report after checking the docs. The label is good here though! my bad I gave you the wrong field name

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.

rules: null,
};

export const TABLE_LINEAGE_MODE: RecipeField = {
name: 'table_lineage_mode',
label: 'Table Lineage Mode',
tooltip: 'Option to enable/disable lineage generation. Is enabled by default.',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's change to "Which table lineage collector mode to use. Check out the documentation explaining the difference between the three available modes." where "the documentation" is a link to https://datahubproject.io/docs/generated/ingestion/sources/redshift/#lineage

type: FieldType.SELECT,
fieldPath: 'source.config.table_lineage_mode',
rules: null,
tableLineages: [
{ 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 +405,28 @@ 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,
INCLUDE_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));
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

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
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