gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 63505d1b: Query: the new format of Gaia's type


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 63505d1b: Query: the new format of Gaia's types for info
Date: Sun, 4 Jun 2023 12:02:31 -0400 (EDT)

branch: master
commit 63505d1b3733ff3f7f54f5d0ccb08254bb292fd1
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Query: the new format of Gaia's types for info
    
    Until now, the Gaia servers used strings like "BIGINT" or "REAL" to
    identify types for 64-bit signed integers or 32-bit floats. However, some
    time in the last few months, this has been changed to the more standard
    "long" or "float" strings (similar name changes for other types). As a
    result, when Query was run with '--information' on any Gaia dataset, it
    would crash because the type was not recognized.
    
    With this commit, after investigating the newly downloaded meta data table,
    this change was discovered and Query's type reading functions were
    corrected to accound for the new type names also.
    
    This bug was found during a discussion with Rashid Yaaqib.
    
    This fixes bug #64246.
---
 NEWS                           |  2 ++
 bin/query/query.c              | 30 +++++++++++++++++++-----------
 bin/script/psf-select-stars.in |  2 +-
 doc/announce-acknowledge.txt   |  1 +
 4 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/NEWS b/NEWS
index 2ab2a7db..41bdc391 100644
--- a/NEWS
+++ b/NEWS
@@ -86,6 +86,8 @@ See the end of the file for license conditions.
               problem in Query by Sepideh Eskandarlou.
   bug #64199: info astscript-zeropoint not working. Reported by Zahra
               Sharbaf.
+  bug #64246: Query's --information gives a crash for Gaia datasets.
+              Reported by Rashid Yaaqib.
   bug #64250: astscript-fits-view: no message printed when input file did
               not exist. Reported by Ryan Begley.
   bug #64274: MakeProfiles crash for points in 3D. Found by Teet Kuumta.
diff --git a/bin/query/query.c b/bin/query/query.c
index 37145f98..8720cb6d 100644
--- a/bin/query/query.c
+++ b/bin/query/query.c
@@ -147,20 +147,27 @@ query_output_meta_database(struct queryparams *p)
 
 
 
+/* Note that these types in TAP are not case-sensitive. */
 static uint8_t
 query_type_from_tap(char *typestr)
 {
   uint8_t type;
-  if(      !strcmp(typestr,"BOOLEAN")  ) type=GAL_TYPE_UINT8;
-  else if( !strcmp(typestr,"BIGINT")   ) type=GAL_TYPE_INT64;
-  else if( !strcmp(typestr,"REAL")     ) type=GAL_TYPE_FLOAT32;
-  else if( !strcmp(typestr,"DOUBLE")   ) type=GAL_TYPE_FLOAT64;
-  else if( !strcmp(typestr,"SMALLINT")
-           || !strcmp(typestr,"INTEGER") ) type=GAL_TYPE_INT32;
-  else if( !strcmp(typestr,"VARCHAR")
-           || !strcmp(typestr,"STRING")
-           || !strncmp(typestr, "CHAR", 4) ) type=GAL_TYPE_STRING;
-  else type=GAL_TYPE_INVALID;
+  if(      !strcasecmp(typestr,"BOOLEAN")  ) type=GAL_TYPE_INT8;
+  else if( !strcasecmp(typestr,"BIGINT")
+           || !strcasecmp(typestr,"LONG") )  type=GAL_TYPE_INT64;
+  else if( !strcasecmp(typestr,"REAL")
+           || !strcasecmp(typestr,"FLOAT") ) type=GAL_TYPE_FLOAT32;
+  else if( !strcasecmp(typestr,"DOUBLE")   ) type=GAL_TYPE_FLOAT64;
+  else if( !strcasecmp(typestr,"SMALLINT")
+           || !strcasecmp(typestr,"SHORT")
+           || !strcasecmp(typestr,"INTEGER") ) type=GAL_TYPE_INT32;
+  else if( !strcasecmp(typestr,"VARCHAR")
+           || !strcasecmp(typestr,"STRING")
+           || !strncasecmp(typestr, "CHAR", 4) ) type=GAL_TYPE_STRING;
+  else
+    error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at '%s' to fix "
+          "the problem. The string '%s' is not a recognized type for "
+          "this function", __func__, PACKAGE_BUGREPORT, typestr);
   return type;
 }
 
@@ -221,6 +228,7 @@ query_output_meta_dataset(struct queryparams *p)
       allcols=gal_data_array_calloc(numcols);
       for(i=0;i<numcols;++i)
         {
+          allcols[i].minmapsize=1; /* The "repeat" for vectors. */
           allcols[i].type=query_type_from_tap(type[i]);
           gal_checkset_allocate_copy(name[i], &allcols[i].name);
           gal_checkset_allocate_copy(desc[i], &allcols[i].comment);
@@ -292,7 +300,7 @@ query_output_finalize(struct queryparams *p)
   fitsfile *fptr;
   int gooddownload=0, status=0;
 
-  /* See if its a FITS file or a VOTable. */
+  /* See if it is a FITS file or a VOTable. */
   len=strlen(p->downloadname);
   if( !strcmp(&p->downloadname[len-4], ".xml") )
     { isxml=1; gooddownload=1; }
diff --git a/bin/script/psf-select-stars.in b/bin/script/psf-select-stars.in
index 0ddd1c7f..c0df1b1e 100644
--- a/bin/script/psf-select-stars.in
+++ b/bin/script/psf-select-stars.in
@@ -324,7 +324,7 @@ do
        -M=*|--mindistdeg=*)    mindistdeg="${1#*=}";                         
check_v "$1" "$mindistdeg";  shift;;
        -M*)                    mindistdeg=$(echo "$1" | sed -e's/-M//');     
check_v "$1" "$mindistdeg";  shift;;
 
-# Output parameters
+   # Output parameters
        -k|--keeptmp)           keeptmp=1; shift;;
        -k*|--keeptmp=*)        on_off_option_error --keeptmp -k;;
        -t|--tmpdir)            tmpdir="$2";                                  
check_v "$1" "$tmpdir";  shift;shift;;
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 0d52568f..34b0736a 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -2,6 +2,7 @@ Alphabetically ordered list to acknowledge in the next release.
 
 Agata Rożek
 Irene Pintos Castro
+Rashid Yaaqib
 Raul Infante-Sainz
 Ryan Begley
 Sepideh Eskandarlou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]