(self, predicate_string)
return components
Parses the components of given predicate string
        Example: 'EQ(t1.ZipCode,t2.ZipCode)' returns [['t1', 'ZipCode'], ['t2','ZipCode']]

        :param predicate_string: predicate string
        :return: list of predicate components
Parses the components of given predicate string
        Example: 'EQ(t1.ZipCode,t2.ZipCode)' returns [['t1', 'ZipCode'], ['t2','ZipCode']]
Parses the components of given predicate string Example : EQ ( t1 . ZipCode t2 . ZipCode ) returns [[ t1 ZipCode ] [ t2 ZipCode ]]
def parse_components(self, predicate_string):
        """
        Parses the components of given predicate string
        Example: 'EQ(t1.ZipCode,t2.ZipCode)' returns [['t1', 'ZipCode'], ['t2','ZipCode']]

        :param predicate_string: predicate string
        :return: list of predicate components
        """
        # HC currently only supports DCs with two tuples per predicate
        # so raise an exception if a different number present
        num_tuples = len(predicate_string.split(','))
        if num_tuples < 2:
            raise Exception('Less than 2 tuples in predicate: ' +
                                    predicate_string)
        elif num_tuples > 2:
            raise Exception('More than 2 tuples in predicate: ' +
                                    predicate_string)

        operation = self.operation_string
        if predicate_string[0:len(operation)] != operation:
            raise Exception('First string in predicate is not operation ' + predicate_string)
        stack = []
        components = []
        current_component = []
        str_so_far = ""
        for i in range(len(operation), len(predicate_string)):
            str_so_far += predicate_string[i]
            if len(stack[-1:]) > 0 and stack[-1] == "'":
                if predicate_string[i] == "'":
                    if i == len(predicate_string) - 1 or \
                            predicate_string[i+1] != ')':
                        raise Exception("Expected ) after end of literal")
                    components.append(str_so_far)
                    current_component = []
                    stack.pop()
                    str_so_far = ""
            elif str_so_far == "'":
                stack.append("'")
            elif str_so_far == '(':
                str_so_far = ''
                stack.append('(')
            elif str_so_far == ')':
                if stack.pop() == '(':
                    str_so_far = ''
                    if len(stack) == 0:
                        break
                else:
                    raise Exception('Closed an unopened (' + predicate_string)
            elif predicate_string[i + 1] == '.':
                if str_so_far in self.tuple_names:
                    current_component.append(str_so_far)
                    str_so_far = ""
                else:
                    raise Exception('Tuple name ' + str_so_far + ' not defined in ' + predicate_string)

            elif (predicate_string[i + 1] == ',' or
                  predicate_string[i + 1] == ')') and \
                    predicate_string[i] != "'":

                # Attribute specified in DC not found in schema
                if str_so_far not in self.schema:
                    raise Exception('Attribute name {} not in schema: {}'.format(str_so_far, ",".join(self.schema)))

                current_component.append(str_so_far)
                str_so_far = ""
                components.append(current_component)
                current_component = []
            elif str_so_far == ',' or str_so_far == '.':
                str_so_far = ''
        return components
def parse_components ( self , predicate_string ) : # HC currently only supports DCs with two tuples per predicate # so raise an exception if a different number present num_tuples = len ( predicate_string . split ( ',' ) ) if num_tuples < 2 : raise Exception ( 'Less than 2 tuples in predicate: ' + predicate_string ) elif num_tuples > 2 : raise Exception ( 'More than 2 tuples in predicate: ' + predicate_string ) operation = self . operation_string if predicate_string [ 0 : len ( operation ) ] != operation : raise Exception ( 'First string in predicate is not operation ' + predicate_string ) stack = [ ] components = [ ] current_component = [ ] str_so_far = "" for i in range ( len ( operation ) , len ( predicate_string ) ) : str_so_far += predicate_string [ i ] if len ( stack [ - 1 : ] ) > 0 and stack [ - 1 ] == "'" : if predicate_string [ i ] == "'" : if i == len ( predicate_string ) - 1 or predicate_string [ i + 1 ] != ')' : raise Exception ( "Expected ) after end of literal" ) components . append ( str_so_far ) current_component = [ ] stack . pop ( ) str_so_far = "" elif str_so_far == "'" : stack . append ( "'" ) elif str_so_far == '(' : str_so_far = '' stack . append ( '(' ) elif str_so_far == ')' : if stack . pop ( ) == '(' : str_so_far = '' if len ( stack ) == 0 : break else : raise Exception ( 'Closed an unopened (' + predicate_string ) elif predicate_string [ i + 1 ] == '.' : if str_so_far in self . tuple_names : current_component . append ( str_so_far ) str_so_far = "" else : raise Exception ( 'Tuple name ' + str_so_far + ' not defined in ' + predicate_string ) elif ( predicate_string [ i + 1 ] == ',' or predicate_string [ i + 1 ] == ')' ) and predicate_string [ i ] != "'" : # Attribute specified in DC not found in schema if str_so_far not in self . schema : raise Exception ( 'Attribute name {} not in schema: {}' . format ( str_so_far , "," . join ( self . schema ) ) ) current_component . append ( str_so_far ) str_so_far = "" components . append ( current_component ) current_component = [ ] elif str_so_far == ',' or str_so_far == '.' : str_so_far = '' return components