Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wren-engine
Submodule wren-engine updated 273 files
17 changes: 17 additions & 0 deletions wren-launcher/commands/dbt/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,23 @@ func ConvertDbtProjectCore(opts ConvertOptions) (*ConvertResult, error) {
"sslMode": typedDS.SslMode,
},
}
case *WrenDorisDataSource:
var host string
if opts.UsedByContainer {
host = handleLocalhostForContainer(typedDS.Host)
} else {
host = typedDS.Host
}
wrenDataSource = map[string]interface{}{
"type": "doris",
"properties": map[string]interface{}{
"host": host,
"port": typedDS.Port,
"database": typedDS.Database,
"user": typedDS.User,
"password": typedDS.Password,
},
}
default:
pterm.Warning.Printf("Warning: Unsupported data source type: %s\n", ds.GetType())
wrenDataSource = map[string]interface{}{
Expand Down
101 changes: 101 additions & 0 deletions wren-launcher/commands/dbt/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ func convertConnectionToDataSource(conn DbtConnection, dbtHomePath, profileName,
return convertToMSSQLDataSource(conn)
case "mysql":
return convertToMysqlDataSource(conn)
case "doris":
return convertToDorisDataSource(conn)
case "bigquery":
// Pass the dbtHomePath to the BigQuery converter
return convertToBigQueryDataSource(conn, dbtHomePath)
Expand Down Expand Up @@ -216,6 +218,25 @@ func convertToMysqlDataSource(conn DbtConnection) (*WrenMysqlDataSource, error)
return ds, nil
}

func convertToDorisDataSource(conn DbtConnection) (*WrenDorisDataSource, error) {
pterm.Info.Printf("Converting Doris data source: %s:%d/%s\n", conn.Host, conn.Port, conn.Database)

port := strconv.Itoa(conn.Port)
if conn.Port == 0 {
port = "9030"
}

ds := &WrenDorisDataSource{
Host: conn.Host,
Port: port,
Database: conn.Database,
User: conn.User,
Password: conn.Password,
}

return ds, nil
}

// convertToBigQueryDataSource converts to BigQuery data source
func convertToBigQueryDataSource(conn DbtConnection, dbtHomePath string) (*WrenBigQueryDataSource, error) {
method := strings.ToLower(strings.TrimSpace(conn.Method))
Expand Down Expand Up @@ -549,6 +570,86 @@ func (ds *WrenMysqlDataSource) MapType(sourceType string) string {
}
}

type WrenDorisDataSource struct {
Database string `json:"database"`
Host string `json:"host"`
Password string `json:"password"`
Port string `json:"port"`
User string `json:"user"`
}

// GetType implements DataSource interface
func (ds *WrenDorisDataSource) GetType() string {
return "doris"
}

// Validate implements DataSource interface
func (ds *WrenDorisDataSource) Validate() error {
if ds.Host == "" {
return fmt.Errorf("host cannot be empty")
}
if ds.Database == "" {
return fmt.Errorf("database cannot be empty")
}
if ds.User == "" {
return fmt.Errorf("user cannot be empty")
}
if ds.Port == "" {
return fmt.Errorf("port must be specified")
}
port, err := strconv.Atoi(ds.Port)
if err != nil {
return fmt.Errorf("port must be a valid number")
}
if port <= 0 || port > 65535 {
return fmt.Errorf("port must be between 1 and 65535")
}
return nil
}

func (ds *WrenDorisDataSource) MapType(sourceType string) string {
sourceType = strings.ToUpper(sourceType)
switch sourceType {
case "CHAR":
return "char"
case "VARCHAR":
return varcharType
case "TEXT", "STRING":
return "text"
case "TINYINT":
return "TINYINT"
case "SMALLINT":
return "SMALLINT"
case "INT", integerSQL:
return "INTEGER"
case "BIGINT", "LARGEINT":
return "BIGINT"
case "FLOAT":
return "FLOAT"
case "DOUBLE":
return "DOUBLE"
case decimalSQL, "NUMERIC":
return decimalSQL
case dateSQL, "DATEV2":
return dateSQL
case datetimeSQL, "DATETIMEV2":
return datetimeSQL
case booleanSQL, "BOOL":
return booleanSQL
case jsonSQL, "JSONB":
return jsonSQL
case "HLL", "BITMAP", "QUANTILE_STATE", "AGG_STATE":
// Doris-specific aggregate types, map to varchar
return varcharType
case "ARRAY", "MAP", "STRUCT", "VARIANT":
// Doris complex types
return jsonSQL
default:
// Return the original type if no mapping is found
return strings.ToLower(sourceType)
}
}

type WrenBigQueryDataSource struct {
Project string `json:"project_id"`
Dataset string `json:"dataset_id"`
Expand Down
14 changes: 14 additions & 0 deletions wren-ui/public/images/dataSource/doris.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions wren-ui/src/apollo/client/graphql/__types__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ export enum DataSourceName {
BIG_QUERY = 'BIG_QUERY',
CLICK_HOUSE = 'CLICK_HOUSE',
DATABRICKS = 'DATABRICKS',
DORIS = 'DORIS',
DUCKDB = 'DUCKDB',
MSSQL = 'MSSQL',
MYSQL = 'MYSQL',
Expand Down
2 changes: 2 additions & 0 deletions wren-ui/src/apollo/server/adaptors/ibisAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export enum SupportedDataSource {
ATHENA = 'ATHENA',
REDSHIFT = 'REDSHIFT',
DATABRICKS = 'DATABRICKS',
DORIS = 'DORIS',
}

const dataSourceUrlMap: Record<SupportedDataSource, string> = {
Expand All @@ -162,6 +163,7 @@ const dataSourceUrlMap: Record<SupportedDataSource, string> = {
[SupportedDataSource.ATHENA]: 'athena',
[SupportedDataSource.REDSHIFT]: 'redshift',
[SupportedDataSource.DATABRICKS]: 'databricks',
[SupportedDataSource.DORIS]: 'doris',
};

export interface TableResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export class DashboardCacheBackgroundTracker {
// Get project and deployment info
const project = await this.projectService.getCurrentProject();
const deployment = await this.deployService.getLastDeployment(project.id);
if (!deployment) {
throw new Error('No deployment found. Please deploy the model first.');
}
const mdl = deployment.manifest;
const hash = uuidv4();

Expand Down
24 changes: 24 additions & 0 deletions wren-ui/src/apollo/server/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
BIG_QUERY_CONNECTION_INFO,
DUCKDB_CONNECTION_INFO,
MYSQL_CONNECTION_INFO,
DORIS_CONNECTION_INFO,
POSTGRES_CONNECTION_INFO,
MS_SQL_CONNECTION_INFO,
WREN_AI_CONNECTION_INFO,
Expand Down Expand Up @@ -197,6 +198,29 @@ const dataSource = {
HostBasedConnectionInfo
>,

// Doris
[DataSourceName.DORIS]: {
sensitiveProps: ['password'],
toIbisConnectionInfo(connectionInfo) {
const decryptedConnectionInfo = decryptConnectionInfo(
DataSourceName.DORIS,
connectionInfo,
);
const { host, port, database, user, password } =
decryptedConnectionInfo as DORIS_CONNECTION_INFO;
return {
host,
port,
database,
user,
password,
};
},
} as IDataSourceConnectionInfo<
DORIS_CONNECTION_INFO,
HostBasedConnectionInfo
>,

// Oracle
[DataSourceName.ORACLE]: {
sensitiveProps: ['password', 'dsn'],
Expand Down
2 changes: 2 additions & 0 deletions wren-ui/src/apollo/server/mdl/mdlBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ export class MDLBuilder implements IMDLBuilder {
return WrenEngineDataSourceType.REDSHIFT;
case DataSourceName.DATABRICKS:
return WrenEngineDataSourceType.DATABRICKS;
case DataSourceName.DORIS:
return WrenEngineDataSourceType.DORIS;
default:
throw new Error(
`Unsupported data source type: ${type} found when building manifest`,
Expand Down
1 change: 1 addition & 0 deletions wren-ui/src/apollo/server/mdl/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export enum WrenEngineDataSourceType {
DUCKDB = 'DUCKDB',
REDSHIFT = 'REDSHIFT',
DATABRICKS = 'DATABRICKS',
DORIS = 'DORIS',

// accepted by the wren engine, but not supported by the wren ui
DATAFUSION = 'DATAFUSION',
Expand Down
9 changes: 9 additions & 0 deletions wren-ui/src/apollo/server/repositories/projectRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export interface MYSQL_CONNECTION_INFO {
ssl: boolean;
}

export interface DORIS_CONNECTION_INFO {
host: string;
port: number;
user: string;
password: string;
database: string;
}

export interface ORACLE_CONNECTION_INFO {
user: string;
password: string;
Expand Down Expand Up @@ -149,6 +157,7 @@ export type WREN_AI_CONNECTION_INFO =
| BIG_QUERY_CONNECTION_INFO
| POSTGRES_CONNECTION_INFO
| MYSQL_CONNECTION_INFO
| DORIS_CONNECTION_INFO
| ORACLE_CONNECTION_INFO
| DUCKDB_CONNECTION_INFO
| MS_SQL_CONNECTION_INFO
Expand Down
6 changes: 6 additions & 0 deletions wren-ui/src/apollo/server/resolvers/dashboardResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ export class DashboardResolver {
// query with cache enabled
const project = await ctx.projectService.getCurrentProject();
const deployment = await ctx.deployService.getLastDeployment(project.id);
if (!deployment) {
throw new Error('No deployment found. Please deploy the model first.');
}
const mdl = deployment.manifest;
await ctx.queryService.preview(response.sql, {
project,
Expand Down Expand Up @@ -163,6 +166,9 @@ export class DashboardResolver {
const { cacheEnabled } = await ctx.dashboardService.getCurrentDashboard();
const project = await ctx.projectService.getCurrentProject();
const deployment = await ctx.deployService.getLastDeployment(project.id);
if (!deployment) {
throw new Error('No deployment found. Please deploy the model first.');
}
const mdl = deployment.manifest;
const data = (await ctx.queryService.preview(item.detail.sql, {
project,
Expand Down
12 changes: 10 additions & 2 deletions wren-ui/src/apollo/server/resolvers/modelResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,11 @@ export class ModelResolver {

// create view
const project = await ctx.projectService.getCurrentProject();
const { manifest } = await ctx.deployService.getLastDeployment(project.id);
const lastDeploy = await ctx.deployService.getLastDeployment(project.id);
if (!lastDeploy) {
throw new Error('No deployment found. Please deploy the model first.');
}
const { manifest } = lastDeploy;

// get sql statement of a response
const response = await ctx.askingService.getResponse(responseId);
Expand Down Expand Up @@ -941,7 +945,11 @@ export class ModelResolver {
const project = projectId
? await ctx.projectService.getProjectById(parseInt(projectId))
: await ctx.projectService.getCurrentProject();
const { manifest } = await ctx.deployService.getLastDeployment(project.id);
const lastDeploy = await ctx.deployService.getLastDeployment(project.id);
if (!lastDeploy) {
throw new Error('No deployment found. Please deploy the model first.');
}
const { manifest } = lastDeploy;
return await ctx.queryService.preview(sql, {
project,
limit: limit,
Expand Down
11 changes: 10 additions & 1 deletion wren-ui/src/apollo/server/resolvers/sqlPairResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ export class SqlPairResolver {
const lastDeployment = await ctx.deployService.getLastDeployment(
project.id,
);
if (!lastDeployment) {
throw new Error('No deployment found. Please deploy the model first.');
}
const manifest = lastDeployment.manifest;

const wrenSQL = await ctx.sqlPairService.modelSubstitute(
Expand All @@ -114,11 +117,17 @@ export class SqlPairResolver {
return safeFormatSQL(wrenSQL, { language: 'postgresql' }) as WrenSQL;
}

private async validateSql(sql: string, ctx: IContext) {
private async validateSql(sql: string | undefined, ctx: IContext) {
if (sql == null) {
return;
}
const project = await ctx.projectService.getCurrentProject();
const lastDeployment = await ctx.deployService.getLastDeployment(
project.id,
);
if (!lastDeployment) {
throw new Error('No deployment found. Please deploy the model first.');
}
const manifest = lastDeployment.manifest;
try {
await ctx.queryService.preview(sql, {
Expand Down
1 change: 1 addition & 0 deletions wren-ui/src/apollo/server/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const typeDefs = gql`
SNOWFLAKE
REDSHIFT
DATABRICKS
DORIS
}

enum RedshiftConnectionType {
Expand Down
Loading