Comment 2 for bug 1443463

Revision history for this message
khaled Bouaziz (khaled-bouaziz) wrote :

From Qifan

Looks like the bug is in the following method

char * ExHdfsScanTcb::extractAndTransformAsciiSourceToSqlRow(int &err,
                                                             ComDiagsArea* &diagsArea)
{
  err = 0;

  1267 if (attr) // this is a needed column. We need to convert
   1268 {
   1269 *(short*)&hdfsAsciiSourceData_[attr->getVCLenIndOffset()] = l en;
   1270 if (attr->getNullFlag())
   1271 {
   1272 if (len == 0)
   1273 *(short *)&hdfsAsciiSourceData_[attr->getNullIndOffset()] = -1;
   1274 else if (memcmp(sourceData, "\\N", len) == 0)
   1275 *(short *)&hdfsAsciiSourceData_[attr->getNullIndOffset()] = -1;
   1276 else
   1277 *(short *)&hdfsAsciiSourceData_[attr->getNullIndOffset()] = 0;
   1278 }

The correct logic should be:

If (\N is the null indicator recorded in meta-data and the current string is “\N” || (\N is not the null indicator and len == 0) )
  *(short *)&hdfsAsciiSourceData_[attr->getNullIndOffset()] = -1;

As a work-around, we can assume \N is the null indicator by default, and comment out line 1272 and 1273 and remove ‘else’ from line 1274.