- Notifications
You must be signed in to change notification settings - Fork254
Databricks DataSource#1763
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
placidic wants to merge4 commits intolowcoder-org:devChoose a base branch fromplacidic:databricks-plugin
base:dev
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
Show all changes
4 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -22,3 +22,4 @@ node_modules | ||
# Local Netlify folder | ||
.netlify | ||
.vscode/settings.json |
1 change: 1 addition & 0 deletionsclient/packages/lowcoder-design/src/icons/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletionsclient/packages/lowcoder-design/src/icons/v1/icon-query-databricks.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletionsclient/packages/lowcoder/src/api/datasourceApi.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletionsclient/packages/lowcoder/src/comps/comps/formComp/generate/databricks.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { | ||
DataSourceTypeConfig, | ||
FullColumnInfo, | ||
generateInsertSql, | ||
QueryDataType, | ||
} from "./dataSourceCommon"; | ||
import { | ||
CompSelection, | ||
dateCompSelection, | ||
allCompSelection, | ||
numberCompSelection, | ||
timeCompSelection, | ||
dateTimeCompSelection, | ||
} from "./comp"; | ||
function getCompSelection(columnType: string): CompSelection | undefined { | ||
if (!columnType) { | ||
return undefined; | ||
} | ||
switch (columnType.toLowerCase()) { | ||
case "bit": | ||
case "tinyint": | ||
case "smallint": | ||
case "int": | ||
case "bigint": | ||
case "dec": | ||
case "decimal": | ||
case "numeric": | ||
case "smallmoney": | ||
case "money": | ||
case "float": | ||
case "real": | ||
return numberCompSelection(true); | ||
case "date": | ||
return dateCompSelection(); | ||
case "datetime": | ||
case "smalldatetime": | ||
return dateTimeCompSelection(); | ||
case "time": | ||
return timeCompSelection(); | ||
} | ||
return allCompSelection(); | ||
} | ||
function getQueryInitData( | ||
formName: string, | ||
tableName: string, | ||
infos: FullColumnInfo[] | ||
): QueryDataType { | ||
return { | ||
compType: "databricks", | ||
comp: { | ||
sql: generateInsertSql(tableName, infos), | ||
commandType: "INSERT", | ||
mode: "SQL", | ||
}, | ||
}; | ||
} | ||
export const databricksConfig: DataSourceTypeConfig = { | ||
type: "databricks", | ||
getCompSelection, | ||
getQueryInitData, | ||
}; |
3 changes: 3 additions & 0 deletionsclient/packages/lowcoder/src/comps/comps/formComp/generate/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionclient/packages/lowcoder/src/comps/queries/queryComp/queryPropertyView.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsclient/packages/lowcoder/src/constants/datasourceConstants.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletionsclient/packages/lowcoder/src/constants/queryConstants.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletionsclient/packages/lowcoder/src/pages/datasource/form/databricksDatasourceForm.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { DatasourceForm, FormInputItem, FormSection, FormSelectItem, FormInputPasswordItem, FormNumberInputItem, FormCheckboxItem } from "lowcoder-design"; | ||
import { DatabricksConfig } from "api/datasourceApi"; | ||
import { DatasourceFormProps } from "./datasourceFormRegistry"; | ||
import { useHostCheck } from "./useHostCheck"; | ||
import { trans } from "i18n"; | ||
import { | ||
DatabaseFormInputItem, | ||
DatasourceNameFormInputItem, | ||
encryptedPlaceholder, | ||
HostFormInputItem, | ||
PasswordFormInputItem, | ||
PortFormInputItem, | ||
SSLFormCheckboxItem, | ||
// UserNameFormInputItem, // removed | ||
} from "../form"; | ||
export const DatabricksDatasourceForm = (props: DatasourceFormProps) => { | ||
const { form, datasource, size } = props; | ||
const datasourceConfig = datasource?.datasourceConfig as DatabricksConfig; | ||
const [usingUri, setUsingUri] = useState(datasourceConfig?.usingUri); | ||
const hostRule = useHostCheck(); | ||
// Set username to "token" if Auth Mechanism is PAT (3) | ||
useEffect(() => { | ||
if (!usingUri && form.getFieldValue("authMechanism") === "3") { | ||
form.setFieldsValue({ username: "token" }); | ||
} | ||
}, [usingUri, form.getFieldValue("authMechanism"), form]); | ||
return ( | ||
<DatasourceForm form={form} preserve={false}> | ||
<FormSection $size={size}> | ||
<DatasourceNameFormInputItem | ||
placeholder={"My DatabricksDB1"} | ||
initialValue={datasource?.name} | ||
/> | ||
</FormSection> | ||
<FormSection $size={size}> | ||
<FormSelectItem | ||
name={"usingUri"} | ||
label={trans("query.connectionType")} | ||
options={[ | ||
{ label: trans("query.regular"), value: "false" }, | ||
{ label: "JDBC URI", value: "true" }, | ||
]} | ||
initialValue={datasourceConfig?.usingUri ? "true" : "false"} | ||
afterChange={(value) => setUsingUri(value === "true")} | ||
/> | ||
</FormSection> | ||
<FormSection $size={size}> | ||
{usingUri ? ( | ||
<FormInputItem | ||
name={"jdbcUri"} | ||
label="JDBC URI" | ||
required={true} | ||
placeholder={encryptedPlaceholder} | ||
rules={[ | ||
{ | ||
required: !datasourceConfig?.usingUri && true, | ||
message: trans("query.uriRequiredMessage"), | ||
}, | ||
{ | ||
pattern: new RegExp( | ||
"^jdbc:databricks:\/\/([a-zA-Z0-9\.-]+):([0-9]{2,5});httpPath=(?:sql\/1\.0\/warehouses\/[a-zA-Z0-9]+|sql\/protocolv1\/o\/[0-9]+\/[0-9]{4}-[0-9]{6}-[a-zA-Z0-9]+);AuthMech=(?:[0-9]+)(?:;[a-zA-Z0-9_]+=[^;]+)*;$" | ||
), | ||
message: trans("query.uriErrorMessage"), | ||
}, | ||
hostRule, | ||
]} | ||
/> | ||
) : ( | ||
<> | ||
<HostFormInputItem initialValue={datasourceConfig?.host} /> | ||
<PortFormInputItem initialValue={"443"} port={datasourceConfig?.port} /> | ||
<FormInputItem | ||
name={"httpPath"} | ||
label="Http Path" | ||
required={true} | ||
placeholder="/sql/1.0/warehouses/xxxxxxxxxxxxxxxx" | ||
initialValue={datasourceConfig?.httpPath} | ||
rules={[ | ||
{ | ||
required: true, | ||
message: "Http Path is required", | ||
}, | ||
]} | ||
/> | ||
<FormSelectItem | ||
name={"authMechanism"} | ||
label={"Auth Mechanism"} | ||
options={[ | ||
{ label: "Personal Access Token", value: "3" } | ||
]} | ||
initialValue={"3"} | ||
// Only one option, so no onChange needed | ||
/> | ||
<FormInputPasswordItem | ||
name={"password"} | ||
label="Access Token" | ||
required={true} | ||
placeholder={encryptedPlaceholder} | ||
initialValue={datasourceConfig?.password} | ||
rules={[ | ||
{ | ||
required: true, | ||
message: "Personal Access Token is required", | ||
}, | ||
]} | ||
/> | ||
<FormInputItem | ||
name={"catalog"} | ||
label="Catalog" | ||
required={false} | ||
placeholder="hive_metastore" | ||
initialValue={datasourceConfig?.catalog} | ||
rules={[]} | ||
/> | ||
<DatabaseFormInputItem | ||
database={datasourceConfig?.database} | ||
label="Schema" | ||
/> | ||
<SSLFormCheckboxItem usingSSl={datasourceConfig?.usingSsl} /> | ||
</> | ||
)} | ||
</FormSection> | ||
</DatasourceForm> | ||
); | ||
}; |
2 changes: 2 additions & 0 deletionsclient/packages/lowcoder/src/pages/datasource/form/datasourceFormRegistry.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionsclient/packages/lowcoder/src/pages/setting/environments/components/DataSourcesTab.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletionsclient/packages/lowcoder/src/util/bottomResUtils.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions.../src/main/java/org/lowcoder/domain/plugin/service/impl/DatasourceMetaInfoServiceImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.