com.dremio.exec.ops.QueryContext.getQueryUserName()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中com.dremio.exec.ops.QueryContext.getQueryUserName方法的一些代码示例,展示了QueryContext.getQueryUserName的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryContext.getQueryUserName方法的具体详情如下:
包路径:com.dremio.exec.ops.QueryContext
类名称:QueryContext
方法名:getQueryUserName

QueryContext.getQueryUserName介绍

[英]Get the user name of the user who issued the query that is managed by this QueryContext.
[中]获取发出此QueryContext管理的查询的用户的用户名。

代码示例

代码示例来源:origin: dremio/dremio-oss

@Before
public void setUp() {
 MockitoAnnotations.initMocks(this);
 // Boilerplate
 AccelerationManager accelerationManager = mock(AccelerationManager.class);
 AccelerationDetailsPopulator populator = mock(AccelerationDetailsPopulator.class);
 when(populator.computeAcceleration()).thenReturn(ByteString.EMPTY_BYTE_ARRAY);
 when(accelerationManager.newPopulator()).thenReturn(populator);
 when(context.getAccelerationManager()).thenReturn(accelerationManager);
 when(context.getQueryUserName()).thenReturn("myuser");
 when(context.getSession()).thenReturn(UserSession.Builder.newBuilder().build());
 when(context.getNonDefaultOptions()).thenReturn(new OptionList());
 when(catalog.getMetadataStatsCollector()).thenReturn(new MetadataStatsCollector());
}

代码示例来源:origin: dremio/dremio-oss

@Override
public List<SimpleCommandResult> toResult(String sql, SqlNode sqlNode) throws Exception {
 final SqlLoadMaterialization load = SqlNodeUtil.unwrap(sqlNode, SqlLoadMaterialization.class);
 if(!SystemUser.SYSTEM_USERNAME.equals(context.getQueryUserName())) {
  throw SqlExceptionHelper.parseError("$LOAD MATERIALIZATION not supported.", sql, load.getParserPosition()).build(logger);
 }
 final ReflectionService service = Preconditions.checkNotNull(context.getAccelerationManager().unwrap(ReflectionService.class),
  "Couldn't unwrap ReflectionService");
 final List<String> components = normalizeComponents(load.getMaterializationPath());
 if (components == null) {
  throw SqlExceptionHelper.parseError("Invalid materialization path.", sql, load.getParserPosition()).build(logger);
 }
 final ReflectionId reflectionId = new ReflectionId(components.get(0));
 final Optional<ReflectionGoal> goalOptional = service.getGoal(reflectionId);
 if (!goalOptional.isPresent()) {
  throw SqlExceptionHelper.parseError("Unknown reflection id.", sql, load.getParserPosition()).build(logger);
 }
 final ReflectionGoal goal = goalOptional.get();
 final MaterializationId materializationId = new MaterializationId(components.get(1));
 final Optional<Materialization> materializationOpt = service.getMaterialization(materializationId);
 if (!materializationOpt.isPresent()) {
  throw SqlExceptionHelper.parseError("Unknown materialization id.", sql, load.getParserPosition()).build(logger);
 }
 final Materialization materialization = materializationOpt.get();
 // if the user already made changes to the reflection goal, let's stop right here
 Preconditions.checkState(Objects.equals(goal.getTag(), materialization.getReflectionGoalVersion()),
  "materialization no longer matches its goal");
 refreshMetadata(goal, materialization);
 return Collections.singletonList(SimpleCommandResult.successful("Materialization metadata loaded."));
}

代码示例来源:origin: dremio/dremio-oss

@Override
public double plan() throws Exception {
 try{
  final RecordingObserver recording = new RecordingObserver();
  final AttemptObservers observers = AttemptObservers.of(observer, recording);
  observers.planStart(sql);
  plan = handler.getPlan(config.cloneWithNewObserver(observers), sql, sqlNode);
  PreparedPlan prepared = new PreparedPlan(context.getQueryId(), context.getQueryUserName(), sql, plan, recording);
  final Long handle = PREPARE_ID.getAndIncrement();
  state = ServerPreparedStatementState.newBuilder()
   .setHandle(handle)
   .setSqlQuery(sql)
   .setPrepareId(context.getQueryId())
   .build();
  planCache.put(handle, prepared);
  // record a partial plan so that we can grab metadata and use it (for example during view creation of via sql).
  observers.planCompleted(new ExecutionPlan(plan, ImmutableList.of(), ImmutableList.of()));
  return 1;
 }catch(Exception ex){
  throw SqlExceptionHelper.coerceException(logger, sql, ex, true);
 }
}

代码示例来源:origin: dremio/dremio-oss

final SqlCompactMaterialization compact = SqlNodeUtil.unwrap(sqlNode, SqlCompactMaterialization.class);
if(!SystemUser.SYSTEM_USERNAME.equals(config.getContext().getQueryUserName())) {
 throw SqlExceptionHelper.parseError("$COMPACT REFRESH not supported.", sql, compact.getParserPosition())
  .build(logger);

代码示例来源:origin: dremio/dremio-oss

final SqlRefreshReflection materialize = SqlNodeUtil.unwrap(sqlNode, SqlRefreshReflection.class);
if(!SystemUser.SYSTEM_USERNAME.equals(config.getContext().getQueryUserName())) {
 throw SqlExceptionHelper.parseError("$MATERIALIZE not supported.", sql, materialize.getParserPosition()).build(logger);

代码示例来源:origin: dremio/dremio-oss

public QueryProfile getQueryProfile(String description, QueryState state, UserException ex, String cancelreason) {
 final QueryProfile.Builder profileBuilder = QueryProfile.newBuilder()
   .setQuery(description)
   .setUser(context.getQueryUserName())
   .setId(queryId)
   .setState(state)

相关文章