Uploaded image for project: 'Pig'
  1. Pig
  2. PIG-4046

PiggyBank DBStorage DATETIME should use setTimestamp with java.sql.Timestamp

VotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.12.1
    • 0.14.0
    • piggybank
    • None
    • CentOS 6.5

    • Reviewed

    Description

      In Pig 0.12.1 PiggyBank DBStorage (contrib/piggybank/java/src/main/java/org/apache/pig/piggybank/storage/DBStorage.java), the code uses the wrong setter and Java data type for the SQL DATETIME datatype.

      DATETIME has both date and time, so should use java.sql.Timestamp instead of java.sql.Date (which zeros the time fields).

      replace line 121
      case DataType.DATETIME:

      • ps.setDate(sqlPos, new Date(((DateTime) field).getMillis()));
        sqlPos++;
        break;
        with
        case DataType.DATETIME:
        + ps.setTimestamp(sqlPos, new Timestamp(((DateTime) field).getMillis(
        )));
        sqlPos++;
        break;

      Attachments

        1. PIG-4046.001.patch
          1 kB
          Shinichi Yamashita

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            sinchii Shinichi Yamashita
            tfriest Timothy Friest
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment