Skip to content

Commit 1acbf05

Browse files
committed
refactor: remove obsolete dimension helpers
1 parent 20c77f7 commit 1acbf05

1 file changed

Lines changed: 0 additions & 96 deletions

File tree

src/mcp/server.ts

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,102 +2861,6 @@ function timeColumnSignal(
28612861
};
28622862
}
28632863

2864-
function detectDimensionColumnCandidates(
2865-
rows: unknown[],
2866-
config: ObConfig,
2867-
schema: string | undefined,
2868-
table: string,
2869-
maxColumns: number
2870-
) {
2871-
return rows
2872-
.map((row, index) => {
2873-
const metadata = profileColumnMetadata(row, config.compatibility);
2874-
if (!metadata) {
2875-
return undefined;
2876-
}
2877-
const signal = dimensionColumnSignal(metadata.name, metadata.dataType, metadata.comment);
2878-
if (signal.confidence < 0.35) {
2879-
return undefined;
2880-
}
2881-
return {
2882-
column: metadata.name,
2883-
kind: signal.kind,
2884-
confidence: signal.confidence,
2885-
evidence: signal.evidence,
2886-
dataType: metadata.dataType,
2887-
typeCategory: profileColumnTypeCategory(metadata.dataType),
2888-
nullable: metadata.nullable,
2889-
comment: metadata.comment,
2890-
masked: shouldMaskColumnValue(metadata.name, config, schema, table),
2891-
ordinalPosition: numberRecordValue(row as Record<string, unknown>, "ordinal_position", "ORDINAL_POSITION", "column_id", "COLUMN_ID") ?? index + 1
2892-
};
2893-
})
2894-
.filter((item): item is NonNullable<typeof item> => Boolean(item))
2895-
.sort((left, right) => right.confidence - left.confidence || left.ordinalPosition - right.ordinalPosition)
2896-
.slice(0, Math.max(1, Math.min(maxColumns, 50)));
2897-
}
2898-
2899-
function dimensionColumnSignal(
2900-
columnName: string,
2901-
dataType: string | undefined,
2902-
comment: string | undefined
2903-
): { kind: string; confidence: number; evidence: string[] } {
2904-
const normalized = columnName.trim().toLowerCase();
2905-
const commentText = (comment ?? "").trim().toLowerCase();
2906-
const typeCategory = profileColumnTypeCategory(dataType);
2907-
const evidence: string[] = [];
2908-
let confidence = 0;
2909-
let kind = "generic_dimension";
2910-
2911-
const namedKind = dimensionKindFromName(normalized);
2912-
if (namedKind) {
2913-
kind = namedKind;
2914-
confidence += 0.55;
2915-
evidence.push(`Column name matches common ${namedKind.replace(/_/g, " ")} naming.`);
2916-
}
2917-
if (["enum", "boolean"].includes(typeCategory)) {
2918-
confidence += 0.3;
2919-
evidence.push(`Type category is ${typeCategory}.`);
2920-
} else if (typeCategory === "string" && /(char|varchar|text|string)/i.test(dataType ?? "")) {
2921-
confidence += 0.15;
2922-
evidence.push("String type can represent a categorical value.");
2923-
} else if (typeCategory === "numeric" && /(tinyint|smallint|number\(1|int\(1)/i.test(dataType ?? "")) {
2924-
confidence += 0.15;
2925-
evidence.push("Small numeric type can represent a code or flag.");
2926-
}
2927-
if (/(status|state|type|category|channel|region|city|province|country|source|platform|flag|level|kind|gender)/.test(commentText)) {
2928-
confidence += 0.15;
2929-
evidence.push("Column comment contains dimension-related wording.");
2930-
}
2931-
return {
2932-
kind,
2933-
confidence: Math.min(0.98, Number(confidence.toFixed(2))),
2934-
evidence
2935-
};
2936-
}
2937-
2938-
function dimensionKindFromName(name: string): string | undefined {
2939-
if (/(^|_)(status|state)(_|$)/.test(name)) {
2940-
return "status";
2941-
}
2942-
if (/(^|_)(type|category|kind|level)(_|$)/.test(name)) {
2943-
return "type";
2944-
}
2945-
if (/(^|_)(channel|source|platform|scene)(_|$)/.test(name)) {
2946-
return "channel";
2947-
}
2948-
if (/(^|_)(region|city|province|country|area)(_|$)/.test(name)) {
2949-
return "region";
2950-
}
2951-
if (/(^|_)(flag|enabled|disabled|deleted|active|valid)(_|$)/.test(name)) {
2952-
return "flag";
2953-
}
2954-
if (/(^|_)(gender|grade|segment|bucket|group)(_|$)/.test(name)) {
2955-
return "category";
2956-
}
2957-
return undefined;
2958-
}
2959-
29602864
function resolveRecentRowsTimeColumn(
29612865
rows: unknown[],
29622866
config: ObConfig,

0 commit comments

Comments
 (0)