LogoLogo
  • Welcome to e6data
  • Introduction to e6data
    • Concepts
    • Architecture
      • e6data in VPC Deployment Model
      • Connect to e6data serverless compute
  • Get Started
  • Sign Up
  • Setup
    • AWS Setup
      • In VPC Deployment (AWS)
        • Prerequisite Infrastructure
        • Infrastructure & Permissions for e6data
        • Setup Kubernetes Components
        • Setup using Terraform in AWS
          • Update a AWS Terraform for your Workspace
        • AWS PrivateLink and e6data
        • VPC Peering | e6data on AWS
      • Connect to e6data serverless compute (AWS)
        • Workspace Creation
        • Catalog Creation
          • Glue Metastore
          • Hive Metastore
          • Unity Catalog
        • Cluster Creation
    • GCP Setup
      • In VPC Deployment (GCP)
        • Prerequisite Infrastructure
        • Infrastructure & Permissions for e6data
        • Setup Kubernetes Components
        • Setup using Terraform in GCP
        • Update a GCP Terraform for your Workspace
      • Connect to e6data serverless compute (GCP)
    • Azure Setup
      • Prerequisite Infrastructure
      • Infrastructure & Permissions for e6data
      • Setup Kubernetes Components
      • Setup using Terraform in AZURE
        • Update a AZURE Terraform for your Workspace
  • Workspaces
    • Create Workspaces
    • Enable/Disable Workspaces
    • Update a Workspace
    • Delete a Workspace
  • Catalogs
    • Create Catalogs
      • Hive Metastore
        • Connect to a Hive Metastore
        • Edit a Hive Metastore Connection
        • Delete a Hive Metastore Connection
      • Glue Metastore
        • Connect to a Glue Metastore
        • Edit a Glue Metastore Connection
        • Delete a Glue Metastore Connection
      • Unity Catalog
        • Connect to Unity Catalog
        • Edit Unity Catalog
        • Delete Unity Catalog
      • Cross-account Catalog Access
        • Configure Cross-account Catalog to Access AWS Hive Metastore
        • Configure Cross-account Catalog to Access Unity Catalog
        • Configure Cross-account Catalog to Access AWS Glue
        • Configure Cross-account Catalog to Access GCP Hive Metastore
    • Manage Catalogs
    • Privileges
      • Access Control
      • Column Masking
      • Row Filter
  • Clusters
    • Edit & Delete Clusters
    • Suspend & Resume Clusters
    • Cluster Size
    • Load Based Sizing
    • Auto Suspension
    • Query Timeout
    • Monitoring
    • Connection Info
  • Pools
    • Delete Pools
  • Query Editor
    • Editor Pane
    • Results Pane
    • Schema Explorer
    • Data Preview
  • Notebook
    • Editor Pane
    • Results Pane
    • Schema Explorer
    • Data Preview
  • Query History
    • Query Count API
  • Connectivity
    • IP Sets
    • Endpoints
    • Cloud Resources
    • Network Firewall
  • Access Control
    • Users
    • Groups
    • Roles
      • Permissions
      • Policies
    • Single Sign-On (SSO)
      • AWS SSO
      • Okta
      • Microsoft My Apps-SSO
      • Icons for IdP
    • Service Accounts
    • Multi-Factor Authentication (Beta)
  • Usage and Cost Management
  • Audit Log
  • User Settings
    • Profile
    • Personal Access Tokens (PAT)
  • Advanced Features
    • Cross-Catalog & Cross-Schema Querying
  • Supported Data Types
  • SQL Command Reference
    • Query Syntax
      • General functions
    • Aggregate Functions
    • Mathematical Functions & Operators
      • Arithematic Operators
      • Rounding and Truncation Functions
      • Exponential and Root Functions
      • Trigonometric Functions
      • Logarithmic Functions
    • String Functions
    • Date-Time Functions
      • Constant Functions
      • Conversion Functions
      • Date Truncate Function
      • Addition and Subtraction Functions
      • Extraction Functions
      • Format Functions
      • Timezone Functions
    • Conditional Expressions
    • Conversion Functions
    • Window Functions
    • Comparison Operators & Functions
    • Logical Operators
    • Statistical Functions
    • Bitwise Functions
    • Array Functions
    • Regular Expression Functions
    • Generate Functions
    • Cardinality Estimation Functions
    • JSON Functions
    • Checksum Functions
    • Unload Function (Copy into)
    • Struct Functions
  • Equivalent Functions & Operators
  • Connectors & Drivers
    • DBeaver
    • DbVisualiser
    • Apache Superset
    • Jupyter Notebook
    • Tableau Cloud
    • Tableau Desktop
    • Power BI
    • Metabase
    • Zeppelin
    • Python Connector
      • Code Samples
    • JDBC Driver
      • Code Samples
      • API Support
    • Configure Cluster Ingress
      • ALB Ingress in Kubernetes
      • GCE Ingress in Kubernetes
      • Ingress-Nginx in Kubernetes
  • Security & Trust
    • Best Practices
      • AWS Best Practices
    • Features & Responsibilities Matrix
    • Data Protection Addendum(DPA)
  • Tutorials and Best Practices
    • How to configure HIVE metastore if you don't have one?
    • How-To Videos
  • Known Limitations
    • SQL Limitations
    • Other Limitations
    • Restart Triggers
    • Cloud Provider Limitations
  • Error Codes
    • General Errors
    • User Account Errors
    • Workspace Errors
    • Catalog Errors
    • Cluster Errors
    • Data Governance Errors
    • Query History Errors
    • Query Editor Errors
    • Pool Errors
    • Connectivity Errors
  • Terms & Condition
  • Privacy Policy
    • Cookie Policy
  • FAQs
    • Workspace Setup
    • Security
    • Catalog Privileges
  • Services Utilised for e6data Deployment
    • AWS supported regions
    • GCP supported regions
    • AZURE supported regions
  • Release Notes & Updates
    • 6th Sept 2024
    • 6th June 2024
    • 18th April 2024
    • 9th April 2024
    • 30th March 2024
    • 16th March 2024
    • 14th March 2024
    • 12th March 2024
    • 2nd March 2024
    • 10th February 2024
    • 3rd February 2024
    • 17th January 2024
    • 9th January 2024
    • 3rd January 2024
    • 18th December 2023
    • 12th December 2023
    • 9th December 2023
    • 4th December 2023
    • 27th November 2023
    • 8th September 2023
    • 4th September 2023
    • 26th August 2023
    • 21st August 2023
    • 19th July 2023
    • 23rd May 2023
    • 5th May 2023
    • 28th April 2023
    • 19th April 2023
    • 15th April 2023
    • 10th April 2023
    • 30th March 2023
Powered by GitBook
On this page
  1. SQL Command Reference

String Functions

This document contains the string functions supported by e6data.

| | - Concatenation Operator

returns the final string expression by concating two expressions

> select 'hello' || 'world';
'helloworld'

> select concat('hello ', 'world')
'hello world'

LIKE - Like Operator

The like operator is used to match a specified pattern in a string expression. The pattern contains regular characters like %, _

select colA from table where colA like 'P_%'

ILIKE - ILike Operator

The ilike is a case-insensitive operator used to match a specified pattern in a string expression. The pattern contains regular characters like %, _

> select colA from table where colA ilike 'P_%'
> select colA from table where colA not ilike 'P_%'

RLIKE - RLike Operator

The ilike is a case-insensitive operator used to match a specified pattern in a string expression. The pattern contains regular characters like %, _

> select 'E6data' RLIKE 'E[0-9][a-z]+'
true

CHARACTER_LENGTH / CHAR_LENGTH / LEN / LENGTH ( <expr> )

Returns the length of a given string expression.

> select character_length('e6data');
6

REPLACE( <expr>, <search> [, <replace> ] )

expr - string expression to be searched/modified. search - string expression to be searched for in the input expression. replace - optional string expression to be replaced with the search expression. Default is an empty string.

Replaces all instances of search with replace in string expression

> select replace('hard worker', 'hard', 'smart');
'smart worker'

> select replace('hard worker', 'hard');
'worker'

TRIM( <expr> )

Trims/removes leading and trailing whitespace in the input string expression.

> select trim('   Fastest database engine  ');
'Fastest database engine'

LTRIM( <expr> )

Removes leading whitespace in the input string expression.

> select ltrim('  Fastest database engine--');
'Fastest database engine--'

RTRIM( <expr> )

Removes trailing whitespace in the input string expression.

> select rtrim('Fastest database engine  ');
'Fastest database engine'

LOWER( <expr> )

Returns the input string expression converted to lowercase characters.

> select lower('FASTEST DataBAse ENgine- 2022');
'fastest database engine- 2022'

UPPER( <expr> )

Returns the input string expression converted to uppercase characters.

> select upper('Fastest database engine- 2022');
'FASTEST DATABASE ENGINE- 2022'

SUBSTRING( <expr>, start, length )

start - numeric expression representing a starting position in the string. length - numeric expression representing the length of the substring.

Returns a substring from an input string expression of the given length beginning from the start index.

Note: Indexing starts from 1.

> select substring('Fastest database engine', 9, 8)
'database'

SUBSTR( <expr>, start, length )

INITCAP( <expr> )

Returns string expression with the first letter of each word converted to uppercase.

> select initcap('hello world');
'Hello World'

CHARINDEX( <expr> , string [, startindex] )

Returns the first occurrence of the starting position of the input expression within string. Default value of startindex is 1.

> select charindex('a', 'abc')
1

> select charindex('a', 'abc', 2)
0

POSITION( <expr> in <expr> from [startindex] )

Returns first occurrence of the starting position of the input expression within string. Default value of startindex is 1.

> select position('6' in 'e6data-e6data');
2

> select position('6' in 'e6data-e6data' from 3);
9

RIGHT ( <string>, <offset> )

Returns the rightmost substring of its input. Offset index starts from 1.

Supported datatypes are string, integer, decimal, date, timestamp

> SELECT right('abc', 2);
bc

LEFT ( <string>, <offset> )

Returns the leftmost substring of its input. Offset index starts from 1

Supported datatypes are string, integer, decimal, date, timestamp

> SELECT left('abc', 2);
ab

LOCATE ( <substring> , <string> [, <start_position> ] )

Returns the position of the first occurrence of a substring in a string

Index starts with 1

> SELECT LOCATE('6', 'e6data');
2
> SELECT LOCATE('6', 'e6data', 3);
0

CONTAINS_SUBSTR( <expr> , <search_value_literal> )

Returns TRUE if the value exists, otherwise returns FALSE.

Supported datatype are, string, integer, decimal, date, timestamp

> SELECT CONTAINS_SUBSTR('abcdef', 'ef');
TRUE

Limitations

  • Complex types are not supported.

  • Unicode characters are not supported.

INSTR( <expr>, subvalue [, position, occurrence] )

Returns the lowest position of subvalue in value.

> SELECT INSTR('helloooooooo','oo', 1, 3)
9

Limitations

  • Complex types are not supported.

SOUNDEX( <expr> )

Returns a string that contains a phonetic representation of the input string/integer.

> select soundex('winter')
w536

SPLIT( <expr>, [delimiter] )

Splits <expr> using the delimiter argument.

The default delimiter is the comma , Supported Datatype are string

> SELECT SPLIT('A-B-C-D-E-F-G-H', '-' )	 
[ A, B, C, D, E, F, G, H ]

Limitations

  • Even after converting to Varchar, the passing of a date or timestamp is not supported.

SPLIT_PART( <expr>, <delimiter>, <position> )

Splits a given <expr> based on the <delimiter> Supported Datatype are string

> SELECT SPLIT_PART('abc@def@ghi','@',2)
def

Limitations

  • Unicode characters are not supported

ASCII( <expr> )

Return the ASCII code for the first character of a given string. Supported Datatype are string

> select ascii('a')
97

REPEAT( <input_string> , <repeat_value> )

Create a string by duplicating the input by number of repetitions specified.

Supported datatypes: string, integer, decimal

> select repeat('a', 4)
aaaa

Usages:

  • Output is NULL, if either <input_string> or <repeat_value> is NULL

  • Unicodes are not supported in <input_string>

ENDSWITH / ENDS_WITH( <expr_1> , <expr_2> )

Returns TRUE if the first expression ends with second expression

Support Datatype is String

> SELECT ENDSWITH('e6data','ta');
true

STARTSWITH / STARTS_WITH( <expr_1> , <expr_2> )

Returns TRUE if the first expression starts with second expression

Support Datatype is String

> SELECT STARTS_WITH('e6data','ta');
false

STRPOS ( <string>, <substring> [, <start_position> ] )

Returns the position of the first occurrence of a substring in a string

Index starts with 1

> SELECT STRPOS('e6data','6');
2
> SELECT STRPOS('e6data','6', 3);
0

LPAD ( <expr>, <length> [, <pad> ] )

LPAD function is used to left-pad a string with a specified character or set of characters to a certain length

> SELECT LPAD('123', 5, '0');
00123

RPAD ( <expr>, <length> [, <pad> ] )

RPAD function is used to right-pad a string with a specified character or set of characters to a certain length

> SELECT RPAD('123', 5, '0');
12300

REVERSE ( <expr> )

Returns the reversed order of characters of string, integer and boolean values

Support datatype: INT/DOUBLE/VARCHAR/BOOLEAN

> select reverse(53);
35

TO_CHAR/TO_VARCHAR ( <expr> )

TO_CHAR/TO_VARCHAR ( <date_or_timestamp_expr> [, '<format>' ] )

This function transforms the given expression into a string.

Support datatype: INT/FLOAT/DOUBLE/STRING/DATE/TIMESTAMP/BOOL

> select to_char(cast('2022-01-02 18:09:22' as timestamp), 'dd MMM yyyy hh:mm:ss a');
02 Jan 2022 06:09:22 PM

Usages:

  1. In the formate string we don’t support # as it is a reserved keyword.

  2. We don’t support format parameter for other data type except for date and timestamp type

PreviousLogarithmic FunctionsNextDate-Time Functions

Last updated 6 months ago

This is an alias of the function

we support java for date and timestamp type. However we are not supporting zone as the format

format string
substring