Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(interactive): Import VARCHAR to GraphScope interactive #3404

Merged
merged 26 commits into from
Dec 14, 2023

Conversation

zhanglei1949
Copy link
Collaborator

@zhanglei1949 zhanglei1949 commented Dec 6, 2023

Import a new data type VARCHAR to GraphScope Interactive.
#3400
#3405

  1. Use VARCHAR in schema. VARCHAR is not a primitive type.

The following Representation can be revised.

property_type:
  var_char:
    max_length: 128
  1. Refactor PropertyType

Previous PropertyType is just a enum.

enum class PropertyType {
  kEmpty,
  kBool,
  kUInt8,
  kUInt16,
  ...
};

To represent VARCHAR, an enum alone is not enough, because we also need to express the maximum length of VARCHAR, i.e. max_length.

namespace impl {

enum class PropertyTypeImpl {
  kEmpty,
  kBool,
  kUInt8,
  kUInt16,
 ...
};

// Stores additional type information for PropertyTypeImpl
union AdditionalTypeInfo {
  uint16_t max_length;  // for varchar
};
}  // namespace impl

struct PropertyType {
  impl::PropertyTypeImpl type_enum;
  impl::AdditionalTypeInfo additional_type_info;

  PropertyType()
      : type_enum(impl::PropertyTypeImpl::kEmpty), additional_type_info() {}
  PropertyType(impl::PropertyTypeImpl type)
      : type_enum(type), additional_type_info() {}
  PropertyType(impl::PropertyTypeImpl type, uint16_t max_length)
      : type_enum(type), additional_type_info({.max_length = max_length}) {
    assert(type == impl::PropertyTypeImpl::kVarChar);
  }

  //get DataType object, like `arrow::bool()`(but arrow returns a shared_ptr)
  static PropertyType empty();
  static PropertyType bool_();
  static PropertyType uint8();
  static PropertyType uint16();

  // different from other functions
  static PropertyType var_char(uint16_t max_length); 
  //...

  static const PropertyType kEmpty;
  static const PropertyType kBool;
  static const PropertyType kUInt8;
  static const PropertyType kUInt16;
  //...

  bool operator==(const PropertyType& other) const;
  bool operator!=(const PropertyType& other) const;
};

@zhanglei1949 zhanglei1949 marked this pull request as draft December 6, 2023 07:53
@zhanglei1949 zhanglei1949 marked this pull request as ready for review December 14, 2023 05:22
@zhanglei1949 zhanglei1949 merged commit 975667e into alibaba:main Dec 14, 2023
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants