Skip to content

Commit

Permalink
feat: add substring function
Browse files Browse the repository at this point in the history
  • Loading branch information
nextchamp-saqib committed Jan 13, 2024
1 parent 95e0b70 commit 843a7e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions frontend/src/utils/query/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export const FUNCTIONS = {
description: 'Replaces occurrences in the column.',
example: 'replace(`category`, "_", "-")',
},
substring: {
syntax: 'substring(column_name, start, end)',
description: 'Extracts part of the column value.',
example: 'substring(`customer`, 0, 5)',
},

// Arithmetic Functions
abs: {
Expand Down
3 changes: 3 additions & 0 deletions insights/insights/query_builders/sql_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ def apply(cls, function, *args):
if function == "replace":
return func.replace(args[0], args[1], args[2])

if function == "substring":
return func.substring(args[0], args[1], args[2])

if function == "concat":
return func.concat(*args)

Expand Down

0 comments on commit 843a7e3

Please sign in to comment.