class VectorWiseDatabaseMeta extends IngresDatabaseMeta implements IDatabase {

    @Override
    public String getFieldDefinition(IValueMeta v, String tk, String pk, boolean useAutoinc,
                                     boolean addFieldname, boolean addCr) {
        String retval = "";

        String fieldname = v.getName();
        int length = v.getLength();
        int precision = v.getPrecision();

        if (addFieldname) {
            retval += fieldname + " ";
        }

        int type = v.getType();
        switch (type) {
            case IValueMeta.TYPE_TIMESTAMP:
            case IValueMeta.TYPE_DATE:
                retval += "TIMESTAMP";
                break;
            case IValueMeta.TYPE_BOOLEAN:
                retval += "CHAR(1)";
                break;
            case IValueMeta.TYPE_NUMBER:
            case IValueMeta.TYPE_INTEGER:
            case IValueMeta.TYPE_BIGNUMBER:
                if (fieldname.equalsIgnoreCase(tk) || // Technical key
                        fieldname.equalsIgnoreCase(pk) // Primary key
                ) {
                    if (useAutoinc) {
                        retval += "GENERATED ALWAYS AS IDENTITY START WITH 1 INCREMENT BY 1";
                    } else {
                        retval += "BIGINT PRIMARY KEY NOT NULL";
                    }
                } else {
                    if (precision == 0) {
                        // integer numbers
                        if (length > 9) {
                            retval += "BIGINT";
                        } else {
                            if (length == -1 || length > 4) { // If the length is undefined or greater than 4, use a standard INTEGER
                                retval += "INTEGER";
                            } else {
                                if (length > 2) {
                                    retval += "SMALLINT";
                                } else {
                                    retval += "INTEGER1";
                                }
                            }
                        }
                    } else {
                        retval += "FLOAT8";
                    }
                }
                break;
            case IValueMeta.TYPE_STRING:
                // Maybe use some default DB String length in case length<=0
                if (length > 0) {
                    if (length > 32000) {
                        retval += "VARCHAR(32000)";
                    } else {
                        retval += "VARCHAR(" + length + ")";
                    }
                } else {
                    retval += "VARCHAR(9999)";
                }
                break;
            default:
                retval += " UNKNOWN";
                break;
        }

        if (addCr) {
            retval += Const.CR;
        }

        return retval;
    }

}