Exemple #1
0
        public Column(Column col)
            : this()
        {
            Name = col.Name;

            IsKey = col.IsKey;

            Input  = col.Input;
            Output = col.Output;

            _data = CreateColumnData(_output, this);
        }
Exemple #2
0
        protected void ColumnRenamed(string newName)
        {
            DcSpace  space  = this.Input.Space;
            DcSchema schema = this.Input.Schema;
            DcColumn column = this;

            //
            // Check all elements of the schema that can store column name (tables, columns etc.)
            // Update their definition so that it uses the new name of the specified element
            //
            List <DcTable> tables = space.GetTables(schema); // schema.AllSubTables;
            var            nodes  = new List <ExprNode>();

            foreach (var tab in tables)
            {
                if (tab.IsPrimitive)
                {
                    continue;
                }

                foreach (var col in tab.Columns)
                {
                    if (col.GetData() == null)
                    {
                        continue;
                    }
                    DcColumnData data = col.GetData();

                    /* REFACTOR: Here essentially we want to manually find all uses and hence have to use dependencies API
                     * if (data.FormulaExpr != null)
                     * {
                     *  nodes = data.FormulaExpr.Find((DcColumn)column);
                     *  nodes.ForEach(x => x.Name = newName);
                     * }
                     */
                }

                // Update table definitions by finding the uses of the specified column
                if (tab.GetData().WhereExpr != null)
                {
                    nodes = tab.GetData().WhereExpr.Find((DcColumn)column);
                    nodes.ForEach(x => x.Name = newName);
                }
            }

            column.Name = newName;
        }
Exemple #3
0
        public Column(string name, DcTable input, DcTable output, bool isKey, bool isSuper)
        {
            Id = Guid.NewGuid();

            Name = name;

            IsKey   = isKey;
            IsSuper = isSuper;

            Input  = input;
            Output = output;

            //
            // Creae storage for the function and its definition depending on the output set type
            //
            _data = CreateColumnData(output, this);
        }
Exemple #4
0
        /* TODO: Notify after deleting
         * public virtual void Remove()
         * {
         *  if (Output != null) Output.InputColumns.Remove(this);
         *  if (Input != null) Input.Columns.Remove(this);
         *
         *  // Notify that a new child has been removed
         *  if (Input != null) ((Table)Input).NotifyRemove(this);
         *  if (Output != null) ((Table)Output).NotifyRemove(this);
         * }
         */
        protected void DeleteColumnPropagate(DcColumn column)
        {
            DcSchema schema = column.Input.Schema;

            //
            // Delete related columns/tables
            //
            if (column.GetData().IsAppendData) // Delete all tables that are directly or indirectly generated by this column
            {
                DcTable gTab  = column.Output;
                var     paths = new PathEnumerator(new List <DcTable>(new DcTable[] { gTab }), new List <DcTable>(), false, ColumnType.GENERATING);
                foreach (var path in paths)
                {
                    for (int i = path.Segments.Count - 1; i >= 0; i--)
                    {
                        this.DeleteTable(path.Segments[i].Output); // Delete (indirectly) generated table
                    }
                }
                this.DeleteTable(gTab); // Delete (directly) generated table
                // This column will be now deleted as a result of the deletion of the generated table
            }
            else if (column.Input.GetData().DefinitionType == TableDefinitionType.PROJECTION) // It is a extracted table and this column is produced by the mapping (depends on function output tuple)
            {
                //DcColumn projDim = column.Input.InputColumns.Where(d => d.Definition.IsAppendData).ToList()[0];
                //Mapping mapping = projDim.Definition.Mapping;
                //PathMatch match = mapping.GetMatchForTarget(new DimPath(column));
                //mapping.RemoveMatch(match.SourcePath, match.TargetPath);
            }

            //
            // Delete all expression nodes that use the deleted column and all references to this column from other objects
            //
            List <DcTable> tables = schema.AllSubTables;
            var            nodes  = new List <ExprNode>();

            foreach (var tab in tables)
            {
                if (tab.IsPrimitive)
                {
                    continue;
                }

                foreach (var col in tab.Columns)
                {
                    if (col.GetData() == null)
                    {
                        continue;
                    }
                    DcColumnData data = col.GetData();

                    /* REFACTOR: Here essentially we want to manually find all uses and hence have to use dependencies API
                     * if (data.FormulaExpr != null)
                     * {
                     *  nodes = data.FormulaExpr.Find(column);
                     *  foreach (var node in nodes) if (node.Parent != null) node.Parent.RemoveChild(node);
                     * }
                     */
                }

                // Update table definitions by finding the uses of the specified column
                if (tab.GetData().WhereExpr != null)
                {
                    nodes = tab.GetData().WhereExpr.Find(column);
                    foreach (var node in nodes)
                    {
                        if (node.Parent != null)
                        {
                            node.Parent.RemoveChild(node);
                        }
                    }
                }
            }
        }