@Override public String apply(ViewFieldType input) { String name = input.getName(); // Qlik needs field names that contain spaces to be surrounded by " so we surround all field names. // If the field name contains a ", we escape it with "" (per http://help.qlik.com/en-US/sense/3.1/Subsystems/Hub/Content/Scripting/use-quotes-in-script.htm) return quoteString(name); } };
@Override public String apply(final ViewFieldType input) { return input.getName(); } });
@Override public String apply(ViewFieldType field) { return field.getName(); } });
@Override public boolean apply(ViewFieldType input) { return !UPDATE_COLUMN.equals(input.getName()); } }).toList();
public static String[] getColumnsLowerCase(DatasetConfig datasetConfig) { final ByteString schemaBytes = DatasetHelper.getSchemaBytes(datasetConfig); if (schemaBytes != null) { Schema schema = Schema.getRootAsSchema(schemaBytes.asReadOnlyByteBuffer()); org.apache.arrow.vector.types.pojo.Schema s = org.apache.arrow.vector.types.pojo.Schema.convertSchema(schema); return s.getFields().stream().map(input -> input.getName().toLowerCase()).toArray(String[]::new); } else { // If virtual dataset was created with view fields if (datasetConfig.getType() == DatasetType.VIRTUAL_DATASET) { final List<ViewFieldType> viewFieldTypes = datasetConfig.getVirtualDataset().getSqlFieldsList(); if (notEmpty(viewFieldTypes)) { return viewFieldTypes.stream().map(input -> input.getName().toLowerCase()).toArray(String[]::new); } } } return new String[0]; }
public Field(ViewFieldType field) { this.name = field.getName(); this.type = DataTypeUtil.getDataType(SqlTypeName.get(field.getType())).name(); }
private DataType getColType(String columnName) throws DatasetVersionNotFoundException { for(ViewFieldType type : getDatasetConfig ().getSqlFieldsList()) { if (type.getName().equals(columnName)) { return DataTypeUtil.getDataType(SqlTypeName.get(type.getType())); } } throw new ClientErrorException("Given column '" + columnName + "' doesn't exist in dataset"); }
public static View fieldTypesToView(String name, String sql, List<ViewFieldType> fieldTypes, List<String> context) { if (fieldTypes == null) { throw new NullPointerException(); } List<FieldType> fields = new ArrayList<>(); for (ViewFieldType sqlField : fieldTypes) { FieldType fieldType = new View.FieldType( sqlField.getName(), en(SqlTypeName.class, sqlField.getType()), sqlField.getPrecision(), sqlField.getScale(), en(TimeUnit.class, sqlField.getStartUnit()), en(TimeUnit.class, sqlField.getEndUnit()), sqlField.getFractionalSecondPrecision(), sqlField.getIsNullable() ); fields.add(fieldType); } return new View(name, sql, fields, context); }
public DatasetSearchUI(DatasetConfig datasetConfig, CollaborationTag collaborationTag) { this.fullPath = datasetConfig.getFullPathList(); this.datasetType = datasetConfig.getType(); if (collaborationTag != null) { this.tags = collaborationTag.getTagsList(); } if (datasetType == DatasetType.VIRTUAL_DATASET) { final VirtualDataset virtualDataset = datasetConfig.getVirtualDataset(); this.parents = virtualDataset.getParentsList(); this.displayFullPath = fullPath; this.context = virtualDataset.getContextList(); this.fields = Lists.newArrayList(); for (ViewFieldType field: virtualDataset.getSqlFieldsList()) { fields.add(new DatasetFieldSearchUI(field.getName(), field.getType())); } this.datasetVersion = virtualDataset.getVersion(); } else { this.displayFullPath = fullPath; this.context = null; this.parents = null; this.fields = null; this.datasetVersion = null; } }
fields.add(new Field(fieldType.getName(), dataType));
/** * @throws UserException if reflection goal is invalid */ public void validate(ReflectionGoal goal) { ReflectionUtils.validateReflectionGoalWithoutSchema(goal); // The dataset that the reflection refers to must exist. DatasetConfig dataset = namespaceService.get().findDatasetByUUID(goal.getDatasetId()); Preconditions.checkNotNull(dataset, "datasetId must reference an existing dataset"); Catalog catalog = catalogService.get().getCatalog(SchemaConfig.newBuilder(SystemUser.SYSTEM_USERNAME).build()); DremioTable table = catalog.getTable(new NamespaceKey(dataset.getFullPathList())); List<ViewFieldType> schemaFields = ViewFieldsHelper.getBatchSchemaFields(table.getSchema()); Map<String, ViewFieldType> schemaMap = Maps.newHashMap(); for (ViewFieldType type : schemaFields) { schemaMap.put(type.getName(), type); } // Array, List, Map, and Union types cannot be used as dimension or measure field. They also cannot be used for sorting, partitioning or distribution in raw reflections. validateFields(goal.getDetails().getDisplayFieldList(), schemaMap, "Display", false); validateMeasures(goal.getDetails().getMeasureFieldList(), schemaMap, "Measure"); validateFields(goal.getDetails().getDistributionFieldList(), schemaMap, "Distribution", true); validateFields(goal.getDetails().getSortFieldList(), schemaMap, "Sort", true); validateFields(goal.getDetails().getPartitionFieldList(), schemaMap, "Partition", true); validateDimensions(goal.getDetails().getDimensionFieldList(), schemaMap); }
boolean isContainConverted = false; for (ViewFieldType sqlType : sqlFields) { if (sqlType.getName().equalsIgnoreCase("s_address")) { isContainOriginal = true; break; if (sqlType.getName().equalsIgnoreCase("s_addr")) { isContainConverted = true; if (sqlType.getName().equalsIgnoreCase("s_address")) { isContainOriginal = true;