Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
11 changes: 11 additions & 0 deletions wren-launcher/commands/dbt/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ func ConvertDbtProjectCore(opts ConvertOptions) (*ConvertResult, error) {
"sslMode": typedDS.SslMode,
},
}
case *WrenDorisDataSource:
wrenDataSource = map[string]interface{}{
"type": "doris",
"properties": map[string]interface{}{
"host": typedDS.Host,
"port": typedDS.Port,
"database": typedDS.Database,
"user": typedDS.User,
"password": typedDS.Password,
},
}
Comment thread
catpineapple marked this conversation as resolved.
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
2 changes: 2 additions & 0 deletions wren-ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM node:18-bookworm-slim AS base

# Install required packages

RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*


# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
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
6 changes: 6 additions & 0 deletions 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 @@ -119,6 +122,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;
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
15 changes: 14 additions & 1 deletion wren-ui/src/apollo/server/services/askingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,9 @@ export class AskingService implements IAskingService {
}
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 eventName = TelemetryEvent.HOME_PREVIEW_ANSWER;
try {
Expand Down Expand Up @@ -973,6 +976,9 @@ export class AskingService implements IAskingService {
}
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 steps = response?.breakdownDetail?.steps;
const sql = safeFormatSQL(constructCteSql(steps, stepIndex));
Expand Down Expand Up @@ -1000,7 +1006,11 @@ export class AskingService implements IAskingService {
input: InstantRecommendedQuestionsInput,
): Promise<Task> {
const project = await this.projectService.getCurrentProject();
const { manifest } = await this.deployService.getLastDeployment(project.id);
const lastDeploy = await this.deployService.getLastDeployment(project.id);
if (!lastDeploy) {
throw new Error('No deployment found. Please deploy the model first.');
}
const { manifest } = lastDeploy;

const response = await this.wrenAIAdaptor.generateRecommendationQuestions({
manifest,
Expand Down Expand Up @@ -1056,6 +1066,9 @@ export class AskingService implements IAskingService {
private async getDeployId() {
const { id } = await this.projectService.getCurrentProject();
const lastDeploy = await this.deployService.getLastDeployment(id);
if (!lastDeploy) {
throw new Error('No deployment found. Please deploy the model first.');
}
return lastDeploy.hash;
}

Expand Down
Loading