Like operator Helper

The LIKE operator uses the following method helper to be transformed:

Important Notice: Migration of Documentation Website

Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:

Official Snowflake Snowconvert Documentation

For any immediate assistance or if you encounter any issues, please contact our support team at [email protected].

Thank you for your understanding.

You might also be interested in Like operator transformation.

Like Operator Helper Function Definition

function LIKE(expr,pattern,esc,cs) {
   function fixPattern(pattern,esc) {
      const specials = '/.*+?|(){}[]\\'.split('');
      var newPattern = "";
      var fix = (c) => specials.includes(c) ? '\\' + c : c;
      for(var i = 0;i < pattern.length;i++) {
         var c = pattern[i];
         if (c === esc) {
            newPattern += pattern[i + 1]
            i++
         } else if (c === '%') {
            newPattern += ".*?"
         } else if (c === '_') {
            newPattern += "."
         } else if (c === '[' || ']') {
            newPattern += c
         } else newPattern += fix(c)
      }
      return newPattern;
   }
   return new RegExp(`^${fixPattern(pattern,esc)}$`,cs ? '' : 'i').exec(expr) != null;
}

Last updated