@Override
    public Expr uncheckedCastTo(Type targetType) throws AnalysisException {
        if (targetType.isDateType()) {
            if (type.equals(targetType)) {
                return this;
            }
            if (targetType.isDate()) {
                return new DateLiteral(this.year, this.month, this.day);
            } else if (targetType.isDatetime()) {
                return new DateLiteral(this.year, this.month, this.day, this.hour, this.minute, this.second,
                        this.microsecond);
            } else {
                throw new AnalysisException("Error date literal type : " + type);
            }
        } else if (targetType.isStringType()) {
            return new StringLiteral(getStringValue());
        } else if (Type.isImplicitlyCastable(this.type, targetType, true)) {
            return new CastExpr(targetType, this);
        }
        Preconditions.checkState(false);
        return this;
    }
@Test
    public void uncheckedCastTo() {
        boolean hasException = false;
        try {
            DateLiteral literal = new DateLiteral("1997-10-07", Type.DATE);
            Expr castToExpr = literal.uncheckedCastTo(Type.DATETIME);
            Assert.assertTrue(castToExpr instanceof DateLiteral);
            Assert.assertEquals(castToExpr.type, Type.DATETIME);

            DateLiteral literal2 = new DateLiteral("1997-10-07 12:23:23", Type.DATETIME);
            Expr castToExpr2 = literal2.uncheckedCastTo(Type.DATETIME);
            Assert.assertTrue(castToExpr2 instanceof DateLiteral);
        } catch (AnalysisException e) {
            e.printStackTrace();
            hasException = true;
        }
        Assert.assertFalse(hasException);
    }