Logo Search packages:      
Sourcecode: relational version File versions  Download package

def relational::parser::node::result_format (   self,
  rels 
)
This function returns a list containing the fields that the resulting relation will have.
Since it needs to know real instances of relations, it requires a dictionary where keys are
the names of the relations and the values are the relation objects.

Definition at line 108 of file parser.py.

                                :
        '''This function returns a list containing the fields that the resulting relation will have.
        Since it needs to know real instances of relations, it requires a dictionary where keys are
        the names of the relations and the values are the relation objects.'''
        if rels==None:            
            return
        
        if self.kind==RELATION:
            return list(rels[self.name].header.attributes)
        elif self.kind==BINARY and self.name in ('-','ᑌ','ᑎ'):
            return self.left.result_format(rels)
        elif self.name=='π':
            l=[]
            for i in self.prop.split(','):
                l.append(i.strip())
            return l
        elif self.name=='*':
            return self.left.result_format(rels)+self.right.result_format(rels)
        elif self.name=='σ' :
            return self.child.result_format(rels)
        elif self.name=='ρ':
            _vars={}
            for i in self.prop.split(','):
                q=i.split('➡')
                _vars[q[0].strip()]=q[1].strip()
            
            _fields=self.child.result_format(rels)
            for i in range(len(_fields)):
                if _fields[i] in _vars:
                    _fields[i]=_vars[_fields[i]]
            return _fields
        elif self.name in ('ᐅᐊ','ᐅLEFTᐊ','ᐅRIGHTᐊ','ᐅFULLᐊ'):
            return list(set(self.left.result_format(rels)).union(set(self.right.result_format(rels))))

Generated by  Doxygen 1.6.0   Back to index