Skip to content
Merged
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
9 changes: 9 additions & 0 deletions backend/backend/application/config_parser/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@
"description": "Tests whether a number is greater than a supplied threshold value ",
"function_type": "Math",
},
"HASH": {
"key": "HASH",
"value": "HASH",
"description": (
"Returns a hash of the concatenated values. Accepts one or more columns."
" \n Example: HASH(col1) or HASH(col1, col2, col3)"
),
"function_type": "Text",
},
"HOUR": {
"key": "HOUR",
"value": "HOUR",
Expand Down
23 changes: 16 additions & 7 deletions backend/formulasql/functions/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,22 @@ def startswith(table, node, data_types, inter_exps):

@staticmethod
def hash(table, node, data_types, inter_exps):
if node['inputs'].__len__() == 2:
e = FormulaSQLUtils.build_ibis_expression(table, data_types, inter_exps, node['inputs'][0]).cast('string')
e2 = FormulaSQLUtils.build_ibis_expression(table, data_types, inter_exps, node['inputs'][1])
e = e.hash(e2)
else:
raise Exception("HASH function requires 1 parameter")
data_types[node['outputs'][0]] = 'string'
inputs = node['inputs']

if not inputs:
raise ValueError("HASH function requires at least 1 parameter")

e = FormulaSQLUtils.build_ibis_expression(
table, data_types, inter_exps, inputs[0]
).cast('string')

for input_node in inputs[1:]:
e = e + FormulaSQLUtils.build_ibis_expression(
table, data_types, inter_exps, input_node
).cast('string')

e = e.hash()
data_types[node['outputs'][0]] = 'numeric'
return e

@staticmethod
Expand Down
35 changes: 24 additions & 11 deletions frontend/src/ide/chat-ai/PastConversationActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const PastConversationActions = memo(function PastConversationActions({
handleUpdate,
}) {
const [confirmDeleteId, setConfirmDeleteId] = useState(null);
const [isDeleting, setIsDeleting] = useState(false);
const [editingId, setEditingId] = useState(null);
const [editValue, setEditValue] = useState("");
const [isSaving, setIsSaving] = useState(false);
Expand Down Expand Up @@ -82,17 +83,29 @@ const PastConversationActions = memo(function PastConversationActions({
if (confirmDeleteId) {
return (
<Space>
<CheckOutlined
onClick={(e) => {
e.stopPropagation();
handleDelete(confirmDeleteId);
}}
className="cursor-pointer past-conversation-action-icon"
/>
<CloseOutlined
onClick={clearConfirmDeleteId}
className="cursor-pointer past-conversation-action-icon"
/>
{isDeleting ? (
<Spin size="small" />
) : (
<>
<CheckOutlined
onClick={async (e) => {
e.stopPropagation();
setIsDeleting(true);
try {
await handleDelete(confirmDeleteId);
} finally {
setIsDeleting(false);
setConfirmDeleteId(null);
}
Comment thread
Deepak-Gnanasekar marked this conversation as resolved.
}}
className="cursor-pointer past-conversation-action-icon"
/>
<CloseOutlined
onClick={clearConfirmDeleteId}
className="cursor-pointer past-conversation-action-icon"
/>
</>
)}
</Space>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,13 @@ function ConfigureJoins({
rhsTable.table_name
);
}
// For Full join, keep only the first criteria and reset operator to EQ
if (value === "Full" && draft[joinIndex].criteria.length > 0) {
draft[joinIndex].criteria = [draft[joinIndex].criteria[0]];
if (draft[joinIndex]?.criteria?.[0]?.condition) {
draft[joinIndex].criteria[0].condition.operator = "EQ";
}
}
Comment thread
tahierhussain marked this conversation as resolved.
});
} else if (key === "alias_name") {
// Update joined_table alias_name for self-join support
Expand Down Expand Up @@ -707,6 +714,7 @@ function ConfigureJoins({
setFilterConditions={setJoinFilterConditions}
columnDetails={transformedColumnDetails}
type="join"
joinType={joinType}
join={joins}
setJoins={setJoins}
joinIndex={joinIndex}
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/ide/editor/no-code-toolbar/formula-editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ const FUNCTION_SIGNATURES = {
description: "Adds interval to date",
},

// Hashing
HASH: {
min: 1,
max: Infinity,
params: ["value1", "[value2]", "..."],
description: "Returns a hash of the concatenated values",
},

// No-arg functions
RANDOM: {
min: 0,
Expand Down
34 changes: 28 additions & 6 deletions frontend/src/ide/editor/no-code-ui/filter/filter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,23 @@ function Filter({

if (dataType === "number") {
inAndNotIn
? setAndSanitizeValue(/[^\d,]/, /[^\d,]/g)
: setAndSanitizeValue(/[^\d]/, /\D/g);
? setAndSanitizeValue(/[^\d,.-]/, /[^\d,.-]/g)
: setAndSanitizeValue(/[^\d.-]/, /[^\d.-]/g);
// Sanitize each numeric segment to prevent malformed values
// like "3.1.4" (multiple dots) or "--3" (multiple minus signs)
const sanitizeNumericSegment = (s) => {
const sign = s.startsWith("-") ? "-" : "";
const rest = (sign ? s.slice(1) : s).replace(/-/g, "");
const parts = rest.split(".");
return (
sign +
parts[0] +
(parts.length > 1 ? "." + parts.slice(1).join("") : "")
);
};
value = inAndNotIn
? value.split(",").map(sanitizeNumericSegment).join(",")
: sanitizeNumericSegment(value);
}
Comment thread
Deepak-Gnanasekar marked this conversation as resolved.
newFilterCondition["condition"][conditionKey][key] = [value];
newFilterCondition["condition"][conditionKey]["type"] = typed;
Expand Down Expand Up @@ -872,11 +887,16 @@ function Filter({
type === "join"
? getOperators(type, lhs.column?.data_type).filter(
(item) => {
if (joinType === "Cross" && item.value !== "EQ") {
if (
["Cross", "Full"].includes(joinType) &&
item.value !== "EQ"
) {
return false;
}

return ["NULL", "NOTNULL"].includes(item.value)
return ["NULL", "NOTNULL", "BETWEEN"].includes(
item.value
)
? false
: true;
}
Expand Down Expand Up @@ -1020,11 +1040,13 @@ function Filter({
icon={<PlusOutlined />}
type="text"
disabled={
// For Full joins, only one condition is allowed (no additional filters)
joinType === "Full" ||
// For joins, only check length limit; for model/source, also check if columns exist
isJoinType
(isJoinType
? filterConditions.length >= 5
: !columnDetails?.columns?.filter?.length ||
filterConditions.length >= 5
filterConditions.length >= 5)
}
>
{filterConditions.length ? "Add another filter" : "Add a filter"}
Expand Down
Loading