Skip to content

Commit cf50acf

Browse files
committed
fix: use left join when adding tables instead of inner join
1 parent 5019431 commit cf50acf

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

CHANGES.rst

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ ipac.nexsci.nasa_exoplanet_archive
1313

1414
- Fixed InvalidTableError for DI_STARS_EXEP and TD tables. [#3189]
1515

16+
simbad
17+
^^^^^^
18+
19+
- fix: when adding a measurement table in the votable_fields, if a measurement table is
20+
empty for an object, there will now be a line with masked values instead of no line in
21+
the result [#3199]
22+
1623
xmatch
1724
^^^^^^
1825

astroquery/simbad/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def _add_table_to_output(self, table):
347347
self.columns_in_output += [_Column(table, column, alias)
348348
for column, alias in zip(columns, alias)]
349349
self.joins += [_Join(table, _Column("basic", link["target_column"]),
350-
_Column(table, link["from_column"]))]
350+
_Column(table, link["from_column"]), "LEFT JOIN")]
351351

352352
def add_votable_fields(self, *args):
353353
"""Add columns to the output of a SIMBAD query.

astroquery/simbad/tests/test_simbad.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def test_add_table_to_output(monkeypatch):
214214
simbad_instance._add_table_to_output("mesDiameter")
215215
assert simbad.core._Join("mesdiameter",
216216
simbad.core._Column("basic", "oid"),
217-
simbad.core._Column("mesdiameter", "oidref")
217+
simbad.core._Column("mesdiameter", "oidref"), "LEFT JOIN"
218218
) in simbad_instance.joins
219219
assert simbad.core._Column("mesdiameter", "bibcode", "mesdiameter.bibcode"
220220
) in simbad_instance.columns_in_output

astroquery/simbad/tests/test_simbad_remote.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ def test_query_object(self):
119119
result = self.simbad.query_object("NGC [0-9]*", wildcard=True)
120120
assert all(matched_id.startswith("NGC") for matched_id in result["matched_id"].data.data)
121121

122+
def test_query_object_with_measurement_table(self):
123+
# regression for #3197
124+
self.simbad.reset_votable_fields()
125+
self.simbad.add_votable_fields("mesdistance")
126+
vega = self.simbad.query_object("vega")
127+
# there is one response line
128+
assert len(vega) == 1
129+
# even if the measurement table is empty
130+
assert bool(vega["mesdistance.dist"][0].mask)
131+
122132
def test_query_criteria(self):
123133
simbad_instance = Simbad()
124134
simbad_instance.add_votable_fields("otype")
@@ -199,7 +209,8 @@ def test_add_votable_fields(self):
199209
# tables also require a join
200210
assert _Join("otypes",
201211
_Column("basic", "oid"),
202-
_Column("otypes", "oidref")) == simbad_instance.joins[0]
212+
_Column("otypes", "oidref"),
213+
"LEFT JOIN") == simbad_instance.joins[0]
203214
# tables that have been renamed should warn
204215
with pytest.warns(DeprecationWarning, match="'iue' has been renamed 'mesiue'.*"):
205216
simbad_instance.add_votable_fields("IUE")

0 commit comments

Comments
 (0)