Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Computed expression from columns of joined tables missing in results #29

Open
kristinriebe opened this issue Nov 5, 2014 · 0 comments

Comments

@kristinriebe
Copy link

Original Query

select abs(f1.x-f2.x) as xdist, f1.fofId, f2.fofId from Bolshoi.FOF as f1, Bolshoi.FOF as f2 where f1.snapnum=416 and f2.snapnum=416 and f1.mass > 5.e13 and f2.mass > 5.e13
Limit 10

Problem
xdist is not calculated and not written to results. All necessary columns (f1.x`, f2.x) are selected, but during the join, the expression is forgotten.
This happens, as soon as I use data from the two joined tables. If I calculated a value based on two columns from the same table (f1.x+f1.y or so), everything works fine.

If I add the computed expression in the where-clause: and abs(f1.x-f2.x) < 0.5
then it will be correctly taken into account in the query plan for filtering the results, but again the value won't be given in the results-table.

Goal
This is needed for being able to match halos from different catalogues based on distance or other properties.

Query Plan

-- CALL paquExec('SELECT `f2`.`x` AS `f2.x`,`f2`.`fofId` AS `f2.fofId`,`f2`.`snapnum` AS `f2.snapnum`,`f2`.`mass` AS `f2.mass` FROM Bolshoi.FOF AS `f2` WHERE ( `f2`.`snapnum` = 416 ) and ( `f2`.`mass` > 5.e13 ) ', 'aggregation_tmp_17895463')
-- CALL paquExec('SELECT `f1`.`fofId` AS `f1.fofId`,`f2`.`f2.fofId` AS `f2.fofId` FROM Bolshoi.FOF AS `f1` JOIN ( SELECT `f2.x`,`f2.fofId`,`f2.snapnum`,`f2.mass` FROM `aggregation_tmp_17895463` ) AS `f2` WHERE ( `f1`.`snapnum` = 416 ) and ( `f1`.`mass` > 5.e13 ) LIMIT 0,10', 'aggregation_tmp_35129861')
-- CALL paquDropTmp('aggregation_tmp_17895463')
-- USE spider_tmp_shard-- SET @i=0-- CREATE TABLE cosmosim_user_kristin.`user--calcissue2` ENGINE=MyISAM SELECT @i:=@i+1 AS `row_id`, `f1.fofId`,`f2.fofId` FROM `aggregation_tmp_35129861` LIMIT 0,10
-- CALL paquDropTmp('aggregation_tmp_35129861')

Desired Query Plan

-- CALL paquExec('SELECT `f2`.`x` AS `f2.x`,`f2`.`fofId` AS `f2.fofId`,`f2`.`snapnum` AS `f2.snapnum`,`f2`.`mass` AS `f2.mass` FROM Bolshoi.FOF AS `f2` WHERE ( `f2`.`snapnum` = 416 ) and ( `f2`.`mass` > 5.e13 ) ', 'aggregation_tmp_17895463')
-- CALL paquExec('SELECT abs( `f1`.`x` - `f2`.`f2.x` ) AS `xdist`,`f1`.`fofId` AS `f1.fofId`,`f2`.`f2.fofId` AS `f2.fofId` FROM Bolshoi.FOF AS `f1` JOIN ( SELECT `f2.x`,`f2.fofId`,`f2.snapnum`,`f2.mass` FROM `aggregation_tmp_17895463` ) AS `f2` WHERE ( `f1`.`snapnum` = 416 ) and ( `f1`.`mass` > 5.e13 ) LIMIT 0,10', 'aggregation_tmp_35129861')
-- CALL paquDropTmp('aggregation_tmp_17895463')
-- USE spider_tmp_shard-- SET @i=0-- CREATE TABLE cosmosim_user_kristin.`user--calcissue2` ENGINE=MyISAM SELECT @i:=@i+1 AS `row_id`, `f1.fofId`,`f2.fofId` FROM `aggregation_tmp_35129861` LIMIT 0,10
-- CALL paquDropTmp('aggregation_tmp_35129861')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant