Skip to content

Commit

Permalink
feat: use the UDF info when planning
Browse files Browse the repository at this point in the history
Signed-off-by: Andres Taylor <andres@planetscale.com>
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
  • Loading branch information
systay committed Apr 15, 2024
1 parent 9e40015 commit 080765c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions go/vt/vtgate/semantics/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (a *analyzer) lateInit() {
aliasMapCache: map[*sqlparser.Select]map[string]exprContainer{},
reAnalyze: a.reAnalyze,
tables: a.tables,
aggrUDFs: a.si.GetAggregateUDFs(),

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Region Sharding example using etcd on ubuntu-22.04

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Local example using consul on ubuntu-22.04

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Local example using etcd on ubuntu-22.04

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Local example using zk2 on ubuntu-22.04

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_basic)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_suite)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_migrate_vdiff2_convert_tz)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_backup)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress_suite)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (ers_prs_newfeatures_heavy)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_multi_tenant)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_tablegc) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_partial_movetables_and_materialize)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress_suite) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_suite) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (12)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Unit Test (Race)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtorc) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_concurrentdml)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (schemadiff_vrepl)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_scheduler)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_queries)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (21)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_gen4)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_across_db_versions)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_throttler_topo)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (topo_connection_cache)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_etcd)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtctlbackup_sharded_clustertest_heavy)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_unsharded)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (22)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_schema_tracker)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_partial_keyspace)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Code Coverage

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtorc)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_tablet_healthcheck_cache)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_tablegc)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_foreignkey_stress)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - Manual

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (mysql80)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (15)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vstream)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_recovery)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_general_heavy)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtbackup)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_v2)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (mysql_server_vault)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_godriver)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_revert)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vschema)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_cellalias)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_schema)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_readafterwrite)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr_xtrabackup)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_consul)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_consul)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_foreign_key_stress)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 10

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 10

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_scheduler) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (schemadiff_vrepl) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr_xtrabackup) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_recovery) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_backup) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (18)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_revert) mysql57

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)) (typecheck)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)) (typecheck)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)) (typecheck)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Unit Test (mysql80)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Unit Test (mysql57)

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)

Check failure on line 81 in go/vt/vtgate/semantics/analyzer.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

a.si.GetAggregateUDFs undefined (type SchemaInformation has no field or method GetAggregateUDFs)
}
a.fk = &fkManager{
binder: a.binder,
Expand Down
27 changes: 25 additions & 2 deletions go/vt/vtgate/semantics/early_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type earlyRewriter struct {
// have happened, and we are introducing or changing the AST. We invoke it so all parts of the query have been
// typed, scoped and bound correctly
reAnalyze func(n sqlparser.SQLNode) error
aggrUDFs []string
}

func (r *earlyRewriter) down(cursor *sqlparser.Cursor) error {
Expand Down Expand Up @@ -500,6 +501,15 @@ func (r *earlyRewriter) rewriteAliasesInGroupBy(node sqlparser.Expr, sel *sqlpar
return
}

func (at *aggrTracker) isAggregateUDF(name sqlparser.IdentifierCI) bool {
for _, aggrUDF := range at.aggrUDFs {
if name.EqualString(aggrUDF) {
return true
}
}
return false
}

func (r *earlyRewriter) rewriteAliasesInHaving(node sqlparser.Expr, sel *sqlparser.Select) (expr sqlparser.Expr, err error) {
currentScope := r.scoper.currentScope()
if currentScope.isUnion {
Expand All @@ -508,14 +518,22 @@ func (r *earlyRewriter) rewriteAliasesInHaving(node sqlparser.Expr, sel *sqlpars
}

aliases := r.getAliasMap(sel)
aggrTrack := &aggrTracker{}
aggrTrack := &aggrTracker{
insideAggr: false,
aggrUDFs: r.aggrUDFs,
}
output := sqlparser.CopyOnRewrite(node, aggrTrack.down, func(cursor *sqlparser.CopyOnWriteCursor) {
var col *sqlparser.ColName

switch node := cursor.Node().(type) {
case sqlparser.AggrFunc:
aggrTrack.popAggr()
return
case *sqlparser.FuncExpr:
if aggrTrack.isAggregateUDF(node.Name) {
aggrTrack.popAggr()
}
return
case *sqlparser.ColName:
col = node
default:
Expand Down Expand Up @@ -565,14 +583,19 @@ func (r *earlyRewriter) rewriteAliasesInHaving(node sqlparser.Expr, sel *sqlpars

type aggrTracker struct {
insideAggr bool
aggrUDFs []string
}

func (at *aggrTracker) down(node, _ sqlparser.SQLNode) bool {
switch node.(type) {
switch node := node.(type) {
case *sqlparser.Subquery:
return false
case sqlparser.AggrFunc:
at.insideAggr = true
case *sqlparser.FuncExpr:
if at.isAggregateUDF(node.Name) {
at.insideAggr = true
}
}

return true
Expand Down
5 changes: 5 additions & 0 deletions go/vt/vtgate/semantics/early_rewriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,11 @@ func TestHavingColumnName(t *testing.T) {
expSQL: "select id, sum(t1.foo) as foo from t1 having sum(foo) > 1",
expDeps: TS0,
warning: "Column 'foo' in having clause is ambiguous",
}, {
sql: "select id, sum(t1.foo) as foo from t1 having custom_udf(foo) > 1",
expSQL: "select id, sum(t1.foo) as foo from t1 having custom_udf(foo) > 1",
expDeps: TS0,
warning: "Column 'foo' in having clause is ambiguous",
}, {
sql: "select id, sum(t1.foo) as XYZ from t1 having sum(XYZ) > 1",
expErr: "Invalid use of group function",
Expand Down

0 comments on commit 080765c

Please sign in to comment.