package engine

import (
	"context"
	"errors"

	"github.com/pingcap-inc/clinic/clinic_data_service/pkg/dto"
)

// ErrInvalidDeltaSource means a storage root contains objects but no usable
// Delta transaction log. Callers must not treat this as an empty optional source.
var ErrInvalidDeltaSource = errors.New("invalid Delta source: objects exist but no Delta transaction log was found")

// QueryEngine 查询引擎接口
type QueryEngine interface {
	// Execute 执行查询
	Execute(ctx context.Context, sql string, dataSource *dto.DataSourceInfo) (*dto.DataProxyQueryResult, error)

	// Name 引擎名称
	Name() string

	// Health 健康检查
	Health(ctx context.Context) error

	// GetDatabase 根据 region 返回引擎的 database/project/dataset 名称
	// 用于 SQL 重写、表管理。region 为空时返回默认值
	GetDatabase(region string) string

	// GetTableSchema 获取表结构
	GetTableSchema(ctx context.Context, database, table, region string) (*dto.SchemaResponse, error)
}
