Skip to content

Commit 48b91d9

Browse files
author
James Cor
committed
first pass at fifx
1 parent e13f1e5 commit 48b91d9

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

sql/analyzer/fix_exec_indexes.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,20 @@ func (s *idxScope) visitChildren(n sql.Node) error {
362362
}
363363
s.children = append(s.children, newC)
364364
}
365+
case *plan.GroupBy:
366+
for _, c := range n.Children() {
367+
newC, cScope, err := assignIndexesHelper(c, s)
368+
if err != nil {
369+
return err
370+
}
371+
s.childScopes = append(s.childScopes, cScope)
372+
s.children = append(s.children, newC)
373+
}
365374
default:
366375
for _, c := range n.Children() {
376+
if _, ok := c.(*plan.GroupBy); ok {
377+
print()
378+
}
367379
newC, cScope, err := assignIndexesHelper(c, s)
368380
if err != nil {
369381
return err
@@ -535,6 +547,24 @@ func (s *idxScope) visitSelf(n sql.Node) error {
535547
n.DestSch[colIdx].Default = newDef.(*sql.ColumnDefaultValue)
536548
}
537549
default:
550+
if proj, isProj := n.(*plan.Project); isProj {
551+
if _, isGb := proj.Child.(*plan.GroupBy); isGb {
552+
for _, e := range proj.Expressions() {
553+
// default nodes can't see lateral join nodes, unless we're in lateral
554+
// join and lateral scopes are promoted to parent status
555+
s.expressions = append(s.expressions, fixExprToScope(e, s.childScopes...))
556+
}
557+
return nil
558+
}
559+
if _, isGb := proj.Child.(*plan.Window); isGb {
560+
for _, e := range proj.Expressions() {
561+
// default nodes can't see lateral join nodes, unless we're in lateral
562+
// join and lateral scopes are promoted to parent status
563+
s.expressions = append(s.expressions, fixExprToScope(e, s.childScopes...))
564+
}
565+
return nil
566+
}
567+
}
538568
if ne, ok := n.(sql.Expressioner); ok {
539569
scope := append(s.parentScopes, s.childScopes...)
540570
for _, e := range ne.Expressions() {
@@ -694,6 +724,12 @@ func fixExprToScope(e sql.Expression, scopes ...*idxScope) sql.Expression {
694724
// don't have the destination schema, and column references in default values are determined in the build phase)
695725

696726
idx, _ := newScope.getIdxId(e.Id(), e.String())
727+
if e.String() == "ref_tbl.id" {
728+
print()
729+
}
730+
if e.String() == "new.id" {
731+
print()
732+
}
697733
if idx >= 0 {
698734
return e.WithIndex(idx), transform.NewTree, nil
699735
}

sql/rowexec/show.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func (b *BaseBuilder) buildDescribeQuery(ctx *sql.Context, n *plan.DescribeQuery
7676
var rows []sql.Row
7777
if n.Format.Plan {
7878
formatString := sql.Describe(n.Child, n.Format)
79+
formatString = strings.Replace(formatString, "\r", "", -1)
7980
for _, l := range strings.Split(formatString, "\n") {
8081
if strings.TrimSpace(l) != "" {
8182
rows = append(rows, sql.NewRow(l))

0 commit comments

Comments
 (0)