public function getNativeDatatype($type, $length=null, $cast=false)
    {
        switch ($type) {
            case Column::TYPE_INTEGER:
                if ($length === null) {
                    $length = Column::DEFAULT_LENGTH_INTEGER;
                }
                switch ($length) {
                    case 16:
                        return 'SMALLINT';
                    case 32:
                        return 'INTEGER';
                    case 64:
                        return 'BIGINT';
                    default:
                        throw new \DomainException("Invalid length for type $type: $length");
                }
            case Column::TYPE_VARCHAR:
                if (!ctype_digit((string)$length) or $length < 1) {
                    throw new \InvalidArgumentException('Invalid length: ' . $length);
                }
                return "VARCHAR($length)";
            case Column::TYPE_TIMESTAMP:
                return 'TIMESTAMP';
            case Column::TYPE_DATE:
                return 'DATE';
            case Column::TYPE_BOOL:
                return 'BOOLEAN';
            case Column::TYPE_BLOB:
                return 'BLOB';
            case Column::TYPE_DECIMAL:
                if (!preg_match('/^([0-9]+),([0-9]+)$/', $length, $components)) {
                    throw new \InvalidArgumentException('Invalid length: ' . $length);
                }
                $precision = (integer)$components[1];
                $scale = (integer)$components[2];
                if ($precision < $scale) {
                    throw new \InvalidArgumentException('Invalid length: ' . $length);
                }
                return "NUMERIC($precision,$scale)";
            case Column::TYPE_FLOAT:
                if ($length === null) {
                    $length = Column::DEFAULT_LENGTH_FLOAT;
                } elseif (!ctype_digit((string)$length) or $length < 1) {
                    throw new \InvalidArgumentException('Invalid length: ' . $length);
                }
                return "FLOAT($length)";
            default:
                throw new \DomainException('Unsupported datatype: ' . $type);
        }
    }