astropy / astropy/astroquery

GAMA query returns columns multiple times

Open
#1,558 4 comments 0 reactions 0 assignees View on GitHub
gama
Dominant language
Python
Stars
791
Forks
451
Avg merge
1d 3h
Merged PRs (30d)
4

Description

Code is
```
import numpy as np
import scipy.stats as st
from astroquery.gama import GAMA
import matplotlib.pyplot as plt

line1 = 'SELECT * FROM VisualMorphology vm'
line2 = ' JOIN StellarMasses sm'
line3 = ' ON vm.CATAID = sm.CATAID'
line4 = ' LIMIT 10'
query = line1 + line2 + line3 + line4
print(query)
result = GAMA.query_sql(query)
print(result)
```
Which prints query as

SELECT * FROM VisualMorphology vm JOIN StellarMasses sm ON vm.CATAID = sm.CATAID LIMIT 10

But fails.
ValueError Traceback (most recent call last)
in
13 query = line1 + line2 + line3 + line4
14 print(query)
---> 15 result = GAMA.query_sql(query)
16 print(result)
17
Same if I add AS i.e
SELECT * FROM VisualMorphology AS vm JOIN StellarMasses AS sm ON vm.CATAID = sm.CATAID LIMIT 10

Same query cut and paste into http://www.gama-survey.org/dr3/query/index.php
Works

Contributor guide

Open the contributing guide

Research direction

Start at the GAMA.query_sql entry point and reproduce the shown JOIN query, including the version that works on the GAMA web service. Trace the reported ValueError and compare how the Python query path handles repeated column names. Done means this query returns successfully without the reported failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.