private void analyzeElements(
     DmdlSemantics environment,
     AstAttribute attribute,
     Map<String, AstAttributeElement> elements,
     HiveFieldTrait trait) {
   trait.setTimestampTypeInfo();
   environment.reportAll(AttributeUtil.reportInvalidElements(attribute, elements.values()));
 }
示例#2
0
 @Override
 public void process(
     DmdlSemantics environment, PropertyDeclaration declaration, AstAttribute attribute) {
   environment.reportAll(AttributeUtil.reportInvalidElements(attribute, attribute.elements));
   CsvFieldDriver.checkFieldType(environment, declaration, attribute, BasicTypeKind.TEXT);
   if (CsvFieldDriver.checkConflict(environment, declaration, attribute)) {
     declaration.putTrait(CsvFieldTrait.class, new CsvFieldTrait(attribute, Kind.FILE_NAME, null));
   }
 }
  private Configuration analyzeConfig(
      DmdlSemantics environment,
      AstAttribute attribute,
      Map<String, AstAttributeElement> elements) {
    AstLiteral charset = take(environment, elements, ELEMENT_CHARSET_NAME, LiteralKind.STRING);
    AstLiteral header = take(environment, elements, ELEMENT_HAS_HEADER_NAME, LiteralKind.BOOLEAN);
    AstLiteral codec = take(environment, elements, ELEMENT_CODEC_NAME, LiteralKind.STRING);
    environment.reportAll(AttributeUtil.reportInvalidElements(attribute, elements.values()));

    Configuration result = new Configuration();
    if (charset != null && checkNotEmpty(environment, ELEMENT_CHARSET_NAME, charset)) {
      result.setCharsetName(charset.toStringValue());
    }
    if (header != null) {
      result.setEnableHeader(header.toBooleanValue());
    }
    if (codec != null && checkNotEmpty(environment, ELEMENT_CODEC_NAME, codec)) {
      result.setCodecName(codec.toStringValue());
    }
    return result;
  }